top | item 9739100

Implement arrow functions in v8

44 points| inglor | 10 years ago |code.google.com | reply

56 comments

order
[+] feld|10 years ago|reply
Do we just link to random commits now? I have no idea what arrow functions are or why it would even matter to half the people who visit this site.

edit: after following 4 links I finally found the bug report about it

https://code.google.com/p/v8/issues/detail?id=2700

[+] bsimpson|10 years ago|reply
Arrow functions are one of the improvements from JS Harmony (which was ratified last night).

This commit moves them from "behind the experimental flag" to "shipping by default" in Chromium. It's a pretty big deal to people who write JS for a living.

[+] towelguy|10 years ago|reply
They are a compact way to write anonymous functions in Javascript, so instead of

    var square = function (a) { return a * a;}
You can write:

    var square = a => a * a;
[+] teraflop|10 years ago|reply
Your link goes to the same page as this post. Was it changed at some point?
[+] rubiquity|10 years ago|reply
Then it seems like the perfect opportunity for you to learn something new and stretch your mind a little.
[+] realusername|10 years ago|reply
I'm glad it's finally arriving, it been working in Firefox for quite a long time and I'm happy to see v8 implementing this ! Arrow functions are so much nicer to read and use.
[+] eueueu|10 years ago|reply

  a=>b<=7
  a>=b<=7
Can you not see the typos possible with this? The less characters you use for something, the more error prone. There's a reason we don't write in regular expression syntax.

Maybe I'm just getting old!

[+] malandrew|10 years ago|reply
Do the stack traces for native arrow functions show up in the stack trace as anonymous functions or is only the parent function registered in the stack trace.
[+] malandrew|10 years ago|reply
Anyone have any idea when destructuring assignment is going to make it into v8?

That is one of the features my colleagues most cite as justification for using babel.js (I wouldn't mind destructuring assigment either). I would love to be able to avoid transpilation since it adds overhead from making out our toolchain more complex and makes debugging more difficult because stack traces and line numbers don't necessarily match up.

[+] bnoordhuis|10 years ago|reply
It's in the works: https://code.google.com/p/v8/issues/detail?id=811

You can tell by the number of CLs that a lot of work has been done already but there are a few more still in progress. It's probably still a few weeks out.

Disclaimer: I don't speak for the V8 team, I'm just an interested onlooker.

[+] cozuya|10 years ago|reply
On the front end you can get babel to work with sourcemaps fairly easily depending on what build tool you use.
[+] z3t4|10 years ago|reply
If you use an anonymous function instead of a named function you'll probably end up writing a comment to clarify ... :P

Sometimes the code explains itself though!?

  allowed = members.filter(member => member.age >= ageLimit);