Fat Arrows do not work well with arguments example (#20595)

* Fat Arrows do not work well with arguments example

* added clarity
pull/34268/head
Vishesh 2018-11-08 20:32:09 -05:00 committed by Christopher McCormack
parent f5d5de59c0
commit 4959c4c111
1 changed files with 7 additions and 0 deletions

View File

@ -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>