This is the second in a series of posts where I explore all the new stuff es6 has to offer, come along and learn vicariously!
If you’ve used any recent js library or framework you might have stumbled upon fat arrows ( or arrow functions) that use the following syntax =>
Well ok then arrows seem to replace the function syntax , but how is that an improvement ?
Compact Syntax in anonymous functions
Another very common instance, is the use of functions as arguments for other functions, with arrow functions the syntax can become somehow clearer.
.this and scope with arrow functions
Have you ever lost track of your global variables or wanted to use a local variable but couldn’t figure out which this to use ? , arrow functions help by making things a little more concise, consider the following cases:
The new es6 arrow syntax brings a more compact/clear way of writting functions, It also helps with scope in some cases, while using them is up to you, recognizing them is no longer optional, so it pays to learn them.
() => You will learn to love me.