ES6 arrow functions, syntax and lexical scoping

Single line function expressions in ES6 are nice.

function (param) {
  return expression
}

Becomes:

param => expression

Which allows you to write much more readable code. This short walk through discusses some of the new JavaScript features you can be using now in combination with Babel. Assuming you’re using a build step this just makes sense. I’m particularly excited about the lexical scoping of “this” in the fat arrow function, which will allow us to avoid setting ‘var this = that;’, or using .bind(this) or .call(this).

Source

Leave a Reply

Your email address will not be published. Required fields are marked *