Arrow functions don't have a prototype property (#25198)

This commit is contained in:
Edy Ionescu
2018-11-26 18:03:29 +02:00
committed by Aditya
parent 5ec14e5928
commit d46dc349f1

View File

@ -85,9 +85,15 @@ An arrow function does not have its own `arguments` object. For example, if you
const myFunc = (...n) => { const myFunc = (...n) => {
console.log('The first argument is', n[0]); console.log('The first argument is', n[0]);
} }
myFunc(10,20,30,40,40); // output: The first argument is 10 myFunc(10,20,30,40,40); // output: The first argument is 10
``` ```
Because of this, an arrow function cannot be used as a constructor, hence there's no need for a `prototype` property.
```javascript
(() => {}).hasOwnProperty('prototype'); // false
```
#### Further Reading #### Further Reading
<a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions' target='_blank' rel='nofollow'>MDN link</a> <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions' target='_blank' rel='nofollow'>MDN link</a>