Since sometime back in the heady days of Firefox 22, Firefox gained the ability to use Fat Arrow Functions in JavaScript. Users of CoffeeScript (or, I guess, C#) will be familiar with the syntax. We’ve been using these in Firefox DevTools code for nearly 6 months.
You can use them today in any shipping Firefox and experiment with them live in theScratchpad or Console.
They look like this:
let x = (args) => { /* some function gunk */ };If you want to call it, you can with x();
Fat Arrow functions have a couple of interesting properties. First and probably most useful is that they gain the scope of the environment they’re defined in. You can’t change the value of this by using a call() or bind() function.
Second, Fat Arrow functions don’t have their own prototype or a constructor. (They have the standard Function prototype). This means trying to use the new operator on a fat arrow function results in a TypeError.
That’s all well and good, but what is the practical application of all of this? ...
Your new post is loading...