Fat Arrows do not work well with arguments example (#20595)
* Fat Arrows do not work well with arguments example * added claritypull/34268/head
parent
f5d5de59c0
commit
4959c4c111
|
@ -80,7 +80,14 @@ function Person(){
|
|||
|
||||
var p = new Person();
|
||||
```
|
||||
An arrow function does not have its own `arguments` object. For example, if you do not know the number of arguments passed to a function, instead of using `arguments` you can use the `rest` operator:
|
||||
```javascript
|
||||
const myFunc = (...n) => {
|
||||
console.log('The first argument is', n[0]);
|
||||
}
|
||||
|
||||
myFunc(10,20,30,40,40); // output: The first argument is 10
|
||||
```
|
||||
#### Further Reading
|
||||
|
||||
<a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions' target='_blank' rel='nofollow'>MDN link</a>
|
||||
|
|
Loading…
Reference in New Issue