As mention in document https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions
Arrow functions do not have prototype property
but when I run this on fiddle, why does it gives an object
?
http://es6console.com/iwyii5vm/
Why it is giving a object?
var Foo = () => {};
console.log(Foo.prototype);
If you run this code in a native ES6 engine, there will not be a prototype
property for arrow functions.
var Foo = () => {};
console.log(Foo.prototype);
However, if the code is being transpiled to ES5 code, it will not be a true arrow function, and it will have a prototype
property.
(Babel is enabled for this snippet)
var Foo = () => {};
console.log(Foo.prototype);
In the case of es6console.com
, a transpiler is being used, which is why you are seeing this behavior.
This seems to be an implementation detail of the way es6console implements es6 features. It works correctly in Chrome, which natively supports arrow functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With