ES6: The features I'm most excited about
111–120 of 144 posts
Re: ES6: The features I'm most excited about
#112The example quoted under "Arrow functions" is NOT "arrow function". It's an enhanced object literal.
Re: ES6: The features I'm most excited about
#113I 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.
Re: ES6: The features I'm most excited about
#114I 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…
Re: ES6: The features I'm most excited about
#115I 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.)
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
#116I 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.)
Re: ES6: The features I'm most excited about
#117Earlier 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.
Re: ES6: The features I'm most excited about
#118Earlier 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…
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
#119I'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.
Welcome to C++.