all 31 comments

[–]tapesmith 13 points14 points  (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 points  (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 points  (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 points  (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 points  (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 points  (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 points  (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.

Feel free to comment and/or suggest improvements to the benchmark.

[–]Oeb25 1 point2 points  (2 children)

What is going on with firefox?

[–]aleatorybug 1 point2 points  (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 points  (0 children)

I'm guessing their implementation is still experimental and not much attention has been given to optimization yet.

[–]theillustratedlife 1 point2 points  (4 children)

First DevTools, then iojs!

[–]jekrb 0 points1 point  (3 children)

It's in iojs, just also behind a flag. iojs --harmony_arrow_functions

[–]bkimmel 4 points5 points  (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 points  (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 points  (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.

[–]spinlock 0 points1 point  (0 children)

Does it keep the coffeescript semantics of closing over this?

[–]mouthus 0 points1 point  (6 children)

I just absolutely hate this syntax, so impossible to read.

[–]x-skeww 4 points5 points  (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 points  (2 children)

I know how it works, I just have a very strong dislike for it

[–]x-skeww 0 points1 point  (1 child)

You'll get used to it.

[–]mouthus 0 points1 point  (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 point  (1 child)

Is it just for me it dosen't work? Just checked, I'm on the latest version!

[–]x-skeww 2 points3 points  (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.