Skip to content

The TC39 group (the panel charged with delivering ES6) has reached consensus on an abbreviated syntax for JavaScript function expressions

Updated: at 03:27 PM

Watch for fat arrow syntax in ES6 along with its hard binding of the this keyword

Some notable characteristics of fat-arrow functions:

  1. No prototype property and can’t be used as constructors

  2. The arguments object is not available

  3. They are always anonymous

  4. this is hard bound to the parent scope where the function is declared

Some practical examples:

//return a new array containing the squares of the original…

[1, 2, 3, 4, 5].map(x => x * x);

//[1, 4, 9, 16, 25]

//capitalize…

[‘caption’, ‘select’, ‘cite’, ‘article’].map(word => word.toUpperCase());

//[‘CAPTION’, ‘SELECT’, ‘CITE’, ‘ARTICLE’]

Read more from the source: JavaScript, JavaScript…