Is there a polyfill
for es6 arrow function?
the following code throws syntax error exception in IE, is there a polyfill
to make IE support arrow functions?
var myFunc = ()=>{
alert('es6');
}
myFunc();
Note: I don't want to use any transpiler
.
Thanks in advance
There is no polyfill for arrow functions. It is a syntax error to write the code you have unless you use a transpiler.
A polyfill can add or fix missing built-in classes, functions, objects... but it cannot modify a compiler's accepted syntax.
I'm pretty green with JS so I have a feeling that this may not qualify as a polyfill... but it does seem to be a 'duct tape' stopgap though. I found a fiddle made by Luis Perez that gives this functionality. I'm still working to better understand arrow functions but it at least does work with one of the MDN arrow function examples. Here's the snippet that after playing with I managed to understand (better at least) lol. I hope it is useful to someone.
Features that add new syntax can not be polyfilled.
I can only think of babel-standalone, which you can think of as a JIT compiler/transpiler (if that is OK with you).