Live data from Hacker News

A summary of ECMAScript 6 features

github.com

11–20 of 54 posts

Re: A summary of ECMAScript 6 features

#11

Earlier quoted context omitted.

Generators have long been used in the Python community for reasons other than callback avoidance (they are lazy sequences). Generators in ES6 (as well as several other features) seem to be inspired by Python. There's no reason we'll have to wait for ES7. Seeing as how good 6 to 5 transpilers already are, I'm sure you'll be able to use await relatively soon.

Generators in Python are a very useful feature (lazy sequences, like you said), so maybe I spoke to soon. However, I don't think people should be lauding this feature as some kind of solution to callback hell. I just feel like priority-wise, users would benefit most from modules (which made it), async/await, maybe class syntactic sugar, then everything else.

> I don't think people should be lauding this feature as some kind of solution to callback hell.

Then async/await is no solution for it either.

Re: A summary of ECMAScript 6 features

#12

ECMAScript 6 is a mess Now there's a completely new function syntax that doesn't use parens and has different scope rules var odds = evens.map(v => v + 1); Enhanced object literals: // Computed (dynamic) property names [ 'prop_' + (() => 42)() ]: 42 what?? So it uses parens if there are no params, but not otherwise? Template Strings: `In JavaScript this is not legal.` Seriously another String delimiter? `Hello ${name…

     var odds = evens.map(v => v + 1);
Is about as readable as it gets (inspired by C#, Java8, CoffeeScript), as a benefit of succinct syntax sugar we get intuitive `this` binding - i.e. pit of success.

    [ 'prop_' + (() => 42)() ]: 42
> what?? So it uses parens if there are no params, but not otherwise?

Again not surprising, a leading `=>` would be a syntax error so `()` is an obvious compromise which can be naturally be extended to add args, e.g:

    evens.map((v) => v + 1)

> Seriously another String delimiter?

    `Hello ${name}, how are you ${time}?`
Yep, String interpolation is incredibly useful especially in JavaScript which does a lot of string munging - this will lead to more succinct, readable code. Should be obvious why they didn't want to break existing JS by re-using "" double-quotes.

> Why aren't we just using #{} like everyone else?

Who's everyone else (Ruby inspired langs)? Scala uses ${1 + 1} or $var shorthand (same as Groovy, Kotlin, JSP EL, Haxe), C# 6 uses {var}, Swift uses \(var) whilst Python and Java have string formats that use %(var)

    var [a, , b] = [1,2,3];
> Is that seriously just whitespace and another comma?

It's clearly ignoring matching the second element. Some languages choose to use `_` as a special ignore placeholder, JavaScript chose not to. Either way is not unintuitive with what it does so that's ok.

The other features are extremely useful if you need them, otherwise you can happily ignore them and use the subset you're comfortable with.

Re: A summary of ECMAScript 6 features

#15
post #14

It's really hard to find browser support information for each of those. And every browser vendor chooses to develop every feature in different pace and order.

do you look into this...its gives you complete idea..

samplestitch.com.s3-website-us-east-1.amazonaws.com

Re: A summary of ECMAScript 6 features

#18
I would have liked to have seen:

* Skinny arrows as a shorthand for functions (for methods and constructors that don't get 'this' from outside.

* Rest parameters with trailing arguments, e.g.:

    function zip (...xs, f) { ... }
Seems like an oversight but I'm sure there was a reason (anyone care to comment?)...

I guess arguments parsing isn't quite dead...

Re: A summary of ECMAScript 6 features

#20
Also keep in mind that Traceur adds its own global runtime, I usually recommend 6to5 instead (despite what the name suggests, it supports some ES7 features as well and even JSX).

Here's a good features comparison table of common transpilers: http://6to5.org/docs/compare/#comparison-to-other-transpiler...

Post reply on HN