Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a polyfill for es6 arrow function?

Tags:

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

like image 964
Rana Avatar asked Sep 22 '17 11:09

Rana


People also ask

When you should not use arrow functions in ES6?

An arrow function doesn't have its own this value and the arguments object. Therefore, you should not use it as an event handler, a method of an object literal, a prototype method, or when you have a function that uses the arguments object.

Are arrow functions ES6?

Introduction. The 2015 edition of the ECMAScript specification (ES6) added arrow function expressions to the JavaScript language. Arrow functions are a new way to write anonymous function expressions, and are similar to lambda functions in some other programming languages, such as Python.

What is the difference between a normal function and an ES6 arrow function?

Since regular functions are constructible, they can be called using the new keyword. However, the arrow functions are only callable and not constructible, i.e arrow functions can never be used as constructor functions. Hence, they can never be invoked with the new keyword.

What are arrow functions in ES6 version of JavaScript?

Arrow functions are anonymous functions (the functions without a name and not bound with an identifier). They don't return any value and can declare without the function keyword. Arrow functions cannot be used as the constructors. The context within the arrow functions is lexically or statically defined.


1 Answers

A polyfill can add or fix missing built-in classes, functions, objects... but it cannot modify a compiler's accepted syntax.

like image 147
Pablo Lozano Avatar answered Sep 18 '22 13:09

Pablo Lozano