Live data from Hacker News

ES6: The features I'm most excited about

justicen.com

111–120 of 144 posts

Re: ES6: The features I'm most excited about

#113

I was just talking to my friend who works at NetFlix on the frontend team about ES6, he is most excited about destructuring `let { name, age, gender } = user;`. I however advocate that the new class syntax is the best part of ES6. Take the following trivial OOP example, which I think reads so much easier a lot like PHP. "use strict"; class Vehicle { constructor(name) { this.kind = 'Vehicle'; this.name = name; } print…

I think it's fair to say that people who want to write object-oriented Javascript are very excited by class. Those of us who have found that the non-OO nature of Javascript is part of what makes it so productive are... much less excited.

yep. personally I've taken a much more functional approach to my javascript development that barely relies on oop.

Re: ES6: The features I'm most excited about

#114

I was just talking to my friend who works at NetFlix on the frontend team about ES6, he is most excited about destructuring `let { name, age, gender } = user;`. I however advocate that the new class syntax is the best part of ES6. Take the following trivial OOP example, which I think reads so much easier a lot like PHP. "use strict"; class Vehicle { constructor(name) { this.kind = 'Vehicle'; this.name = name; } print…

I'm with him, I'm pretty excited about destructing coming to JS. If it's half as powerful as it is in clojure it'll be great.

Re: ES6: The features I'm most excited about

#115
post #60

I think .bind(this) could be added as a (more common?) alternative example to var self = this; Personally I'm most excited about the module system. It's by far the most confusing thing for our students (and hard to google since you end up going down the rabbit hole of build systems etc.)

There is a proposal for a :: bind operator.

1. a unary :: operator for binding methods to their objects: `foo.then(::console.log)`

2. a binary :: operator for chaining: `x(a)::y(b)` (equivalent to `y.call(x(a), b)`)

Re: ES6: The features I'm most excited about

#116
post #100

I was a little confused by the constructor for Player in the class example. Wouldn't the following be more appropriate: constructor(x = 0, y = 0) { this.x = x; this.y = y; } (i.e. this way if "new Archer('Legolas', 5, 6);" the x and y values will not be ignored.)

Sure that works too, plus its a great way to point out initializing default arguments.

Re: ES6: The features I'm most excited about

#117
post #57
post #34

Earlier quoted context omitted.

I'd think it would return the original promise, for chaining.

No, it returns a new Promise that's already been resolved to the value you returned previously.

Not quite :) See my paste above, it returns a new Promise in pending state that will return the value in the new then block ("5" here), possibly immediately. (i.e. pending for one event loop tick, then resolved)

Re: ES6: The features I'm most excited about

#118
post #13

Earlier quoted context omitted.

Hm, at first glance I am as well, especially with tagged template strings. Those look particularly simple but powerful. Generally though, is it reasonable for features such as these to be included at the language level? I primarily use ES5 JavaScript so I'm used to pulling in a decent amount of modules (in this case handlebars, underscore, etc.) for things like templating. But I will be relieved to have a language-st…

Most modern languages already have this feature, JavaScript's the strange one to not have a quick way of putting variables into a string and the first to have to name it though because it was missing it for so long. And by your comment have evidentally chosen a confusing name. This isn't to replace templating engines. Admittedly you could trivially extend the string prototype to have something more akin to string.for…

And still you cant 'lazily' store string vars without evaluating.

In python you can save a string like: template = '%s is %s' and _then_ evaluate its output: print template % ('john', 'tall')

Re: ES6: The features I'm most excited about

#119
post #86

I'm a bit worried about ES6 making the language harder to understand. For example, scoping: For backwards compatibility reasons, var has to stay function scoped. But now we also have let, which has different scoping rules. Also, Symbols: [Symbol.iterator]() - what? Why?! On the other hand, stuff like arrow functions, template strings, modules and tail optimization are awesome.

> I'm a bit worried about ES6 making the language harder to understand.

Welcome to C++.

Post reply on HN