ES2015 (or ES6) has added arrow function expressions to JavaScript. These functions have shorter syntax than their predecessor (this being the function expressions) and they are roughly the equivalent of lambda functions in Python or blocks in Ruby. Arrow functions are anonymous functions with a special syntax that accept arguments and operate in the context of their enclosing scope. They provide two main benefits over regular functions; first, their syntax is more concise, and second, managing this in arrow functions is easier.

In this article, I will discuss the differences between the syntax of function expressions, function declarations and arrow functions, lexical scope, arrow functions as object methods, and some shorthands for using them.

#function #javascript #javascript-tips

Understanding Arrow Functions in JavaScript
1.95 GEEK