Arrow Functions Coming to Chrome 45
wingolog.org
wingolog.org
> There they all seem to talk about various minor security fixes in the stable channel posts, but almost never are new features highlighted. Is it really necessary to track the beta and canary release notes and svn logs to stay on top of things?
New JS features and the like seem to be announced on the chromium blog (not the chrome releases blog), but often only with Beta releases. 45 hasn't hit Beta yet, so...
But the most complete official source of information on feature status isn't a blog, its https://www.chromestatus.com/features
(
(
{},
{},
({},{})=>({},{})
)=>
(({},{})=>({},{}),{},{})
)({},{})
I can rewrite that to be more clear: //(({},{})=>({},{}),{},{}) evaluates to {}
//({},{}) evaluates to {}
let fn = ({}, {}, ({},{})=>{}) => {};
fn({},{});
This is just a syntax error, I guess (hope)?In the case of `this`, I can see why they did that: it is the right semantics and all of JavaScript should be this way. But I really think creating two different behaviors for what should all just be syntactic sugar around the same, ol' function values is long-term going to reveal itself as a mistake.
But that's just `this`. I can't for the life of me imagine why they also did this for `arguments`.
Last I checked, using any ES6 syntax causes v8 to permanently deopt the containing function - even using let/const to declare an unused variable that would get removed as dead code. It'll be great once that starts changing..
basically it is a 'fix' to a unusual but completely working and simple to reason about programming feature by adding a more correct but very inconsistent with the rest of the language that makes the whole thing harder to reason about.
does it serve any other benefit? I might be missing something as many people love this feature.
products
.Where(p => p.Price >= range.low && p.Price <= range.high)
.GroupBy(p => p.Category)
.Select(g => new { Category = g.Key.Name, Count = g.Count() })
It's not just about saving a few characters. It's about about making certain types of libraries readable by reducing the amount of noise.Yes, as stated in the linked article:
> arrow functions don't define this or arguments in their bodies, instead capturing these values from the environment
Also:
https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functio...
The arrow operator is indeed syntactic sugar for binding `this` to the function. It's not really necessary, but it makes it much easier to do what you expect to do 99% of the time.
Yes, it sucks that there are now two slightly different ways of doing things, but it's better than breaking all of the existing code currently in use. Hopefully, linters and analysis tools will mark `var` and non-arrow functions as deprecated soon after the major engines support ES6.