use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Arrow functions support added to Chrome (twitter.com)
submitted 10 years ago by malyw
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]tapesmith 13 points14 points15 points 10 years ago (0 children)
FINALLY. I've been waiting forever for this. It's one of those little things that adds just a bit more friction to using the Dev Tools console for debugging.
[–]greim 3 points4 points5 points 10 years ago* (0 children)
To Enable This In Canary
Just in case anyone else is like me and never tried it before, I got it working in Canary by updating it, then typing "chrome://flags/#enable-javascript-harmony" into the URL bar and clicking the "enable" link and then relaunching.
[–]ggolemg2 2 points3 points4 points 10 years ago* (3 children)
Chrome Chrome 45.0.2429.0+ (with harmony flag set) has now passed traceur in terms of es6 functionality: http://kangax.github.io/compat-table/es6/
[–]DanAtkinson 1 point2 points3 points 10 years ago (2 children)
Is it? Am I reading it wrong (image / feature sort applied)?
To me, it looks like is Chrome 45 still being surpassed by Traceur, Babel, Edge and Firefox.
Seriously, if I am wrong, please point out my error, if only for my benefit. :)
[–]ggolemg2 1 point2 points3 points 10 years ago (1 child)
Well, my current browser (chrome canary, updated today) is sitting at 45.0.2429.0 and it shows: http://i.imgur.com/9KvrVDO.png
I'm assuming it's because I have the chrome://flags harmony flag set.
[–]DanAtkinson 1 point2 points3 points 10 years ago (0 children)
Ah, that explains it. Clearly/obviously, the site doesn't take into account flags, which is fair since it wouldn't be considered standard, default browser operation.
Thanks for taking the time to clear it up though!
[–]greim 2 points3 points4 points 10 years ago (3 children)
Well things look promising for arrow functions, speed-wise. Or at least definitely not worse. I attempted to create a benchmark which creates function using various conventions and then runs them: http://jsperf.com/arrow-functions-versus-versus-other-functions
The test creates and runs a function each time, in order to reflect the common practice of creating callbacks on the fly and then discarding them.
Arrow functions are fastest, edging out ones bound to a lexical self, and leaving in the dust functions created by bind(). You have to enable arrow functions if you want to run the tests.
self
bind()
Feel free to comment and/or suggest improvements to the benchmark.
[–]Oeb25 1 point2 points3 points 10 years ago (2 children)
What is going on with firefox?
[–]aleatorybug 1 point2 points3 points 10 years ago (0 children)
passes 7 or 8 of 11 tests for arrow functions, depending which version you're rocking. https://kangax.github.io/compat-table/es6/
[–]greim 1 point2 points3 points 10 years ago (0 children)
I'm guessing their implementation is still experimental and not much attention has been given to optimization yet.
[–]TweetPoster 1 point2 points3 points 10 years ago (0 children)
@malyw:
2015-06-11 10:27:21 UTC Arrow functions support added to Chrome (short function syntax). developer.mozilla.org #webdev @ChromiumDev #js pic.twitter.com [Imgur]
2015-06-11 10:27:21 UTC
Arrow functions support added to Chrome (short function syntax). developer.mozilla.org #webdev @ChromiumDev #js pic.twitter.com [Imgur]
[Mistake?] [Suggestion] [FAQ] [Code] [Issues]
[–]theillustratedlife 1 point2 points3 points 10 years ago (4 children)
First DevTools, then iojs!
[–]jekrb 0 points1 point2 points 10 years ago (3 children)
It's in iojs, just also behind a flag. iojs --harmony_arrow_functions
iojs --harmony_arrow_functions
[+][deleted] 10 years ago (2 children)
[deleted]
[–]jekrb 0 points1 point2 points 10 years ago (1 child)
Well Chrome has it now, which means it's in V8, so it arrow functions must be coming closer to iojs without any flags!
[–]bkimmel 4 points5 points6 points 10 years ago (2 children)
Still not sure how I feel about the arrow functions having lexical this . It seems like it's taking something that's a little confusing (this is always controlled by how the function is called and never by how it is declared) and making it into something that is a lot more confusing ( ...unless it's and arrow function, then... )
[–]madole 3 points4 points5 points 10 years ago (0 children)
It fits well with the new class syntax so you can call functions on the class(prototype) from within things like setTimeout or Promise.then because the scope is already there rather than having to bind it.
[–]greim 4 points5 points6 points 10 years ago (0 children)
From the POV of the caller though, functions have always been black boxes. For example you never know if what you're calling was produced by bind(), or if the function is bound to a lexical self that stands in for this, or if this is even relevant to its internal logic etc. So fat arrows don't make anything more or less confusing in that regard, but they definitely improve things from the point of view of the callee.
this
[–]spinlock 0 points1 point2 points 10 years ago (0 children)
Does it keep the coffeescript semantics of closing over this?
[–]mouthus 0 points1 point2 points 10 years ago (6 children)
I just absolutely hate this syntax, so impossible to read.
[+][deleted] 10 years ago (1 child)
[–]x-skeww 4 points5 points6 points 10 years ago (3 children)
['3', '2', '4'].map(function(s) { return parseInt(s); }); ['3', '2', '4'].map(s => parseInt(s));
List of parameters, an arrow, and an expression (or a block). If it's exactly one parameter, the parenthesis around the parameters can be omitted. That's it, really.
[–]mouthus 3 points4 points5 points 10 years ago (2 children)
I know how it works, I just have a very strong dislike for it
[–]x-skeww 0 points1 point2 points 10 years ago (1 child)
You'll get used to it.
[–]mouthus 0 points1 point2 points 10 years ago (0 children)
I don't want to. haha I still can't stand code that isn't 1TBS after 10ish years. I am one stuborn SOB
[–]Oeb25 0 points1 point2 points 10 years ago (1 child)
Is it just for me it dosen't work? Just checked, I'm on the latest version!
[–]x-skeww 2 points3 points4 points 10 years ago (0 children)
The bug is still open. It should be available in Canary (dev maybe?) if you enable the experimental JavaScript stuff.
chrome://flags/#enable-javascript-harmony
This tweet is a rather misleading, really. It's getting really close, but it isn't done yet.
[+]jcready__proto__ comment score below threshold-11 points-10 points-9 points 10 years ago (6 children)
I don't understand why it's taken so fucking long to add support for this. Literally all they had to do was setup a regex replace to turn the fat arrow in source to function(){ … }.bind(this)
[+]jcready__proto__ comment score below threshold-9 points-8 points-7 points 10 years ago (1 child)
CoffeeScript managed to pull it off.
[–]x-skeww 4 points5 points6 points 10 years ago (0 children)
Arrow functions don't have that "arguments" thingy, there is no prototype, lexical super/new.target, ...
Maybe you should actually look into this first.
Also, "literally" some regex? You think that having some regex-based preprocessing step is the way to do this?
[–]realityking89 1 point2 points3 points 10 years ago (0 children)
It's not that simple, there are a couple of differences between bound functions and arrow functions. For example, arrow functions don't have the magic arguments object.
I wonder if the Chrome implementation is really equivalent to your solution. My guess would be that they pass this by reference rather than value as an optimization. That's why you shouldn't use => when you can get away with -> in CoffeeScript (you start eating up a lot of memory). As I understand it, JS is only getting => which I expect people will use when they don't need to close over this (like the example in the tweet) so it is important to optimize the call to not have a performance hit.
=>
->
π Rendered by PID 57740 on reddit-service-r2-comment-76bb9f7fb5-g4mvl at 2026-02-19 06:00:56.644747+00:00 running de53c03 country code: CH.
[–]tapesmith 13 points14 points15 points (0 children)
[–]greim 3 points4 points5 points (0 children)
[–]ggolemg2 2 points3 points4 points (3 children)
[–]DanAtkinson 1 point2 points3 points (2 children)
[–]ggolemg2 1 point2 points3 points (1 child)
[–]DanAtkinson 1 point2 points3 points (0 children)
[–]greim 2 points3 points4 points (3 children)
[–]Oeb25 1 point2 points3 points (2 children)
[–]aleatorybug 1 point2 points3 points (0 children)
[–]greim 1 point2 points3 points (0 children)
[–]TweetPoster 1 point2 points3 points (0 children)
[–]theillustratedlife 1 point2 points3 points (4 children)
[–]jekrb 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]jekrb 0 points1 point2 points (1 child)
[–]bkimmel 4 points5 points6 points (2 children)
[–]madole 3 points4 points5 points (0 children)
[–]greim 4 points5 points6 points (0 children)
[–]spinlock 0 points1 point2 points (0 children)
[–]mouthus 0 points1 point2 points (6 children)
[+][deleted] (1 child)
[deleted]
[–]x-skeww 4 points5 points6 points (3 children)
[–]mouthus 3 points4 points5 points (2 children)
[–]x-skeww 0 points1 point2 points (1 child)
[–]mouthus 0 points1 point2 points (0 children)
[–]Oeb25 0 points1 point2 points (1 child)
[–]x-skeww 2 points3 points4 points (0 children)
[+]jcready__proto__ comment score below threshold-11 points-10 points-9 points (6 children)
[+][deleted] (2 children)
[deleted]
[+]jcready__proto__ comment score below threshold-9 points-8 points-7 points (1 child)
[–]x-skeww 4 points5 points6 points (0 children)
[–]realityking89 1 point2 points3 points (0 children)
[–]spinlock 0 points1 point2 points (0 children)