Live data from Hacker News

ES6: The features I'm most excited about

justicen.com

21–30 of 144 posts

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

#21

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.

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

#22
post #17

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, b…

async/await solves error handling and hanging onto values quite nicely. IMO you should use Babel and take advantage.

I am using Babel already. Not sure I'm ready to dip into ES7 features though. ES6 feels bleeding-edge enough for me.

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

#23
post #2

My favourite feature is promises, while it doesn't add a new syntax and you can probably add a library for it, the fact it's standardised makes a world of difference. Now that it's standardised 1. It will become the common interface for deferred operations and library authors can make assumptions that it's there. 2. ES7 Async/Await will be able to leverage this common interface.

My problem with promises is that delivering it without async/await is just awkward. Because, yes, in the ES7 async/await world, you're going to want to use promises heavily because they'll work so great with that.

But in the ES6 world, making your API promise-based makes it heavier-feeling and more awkward than simple, clean callbacks. (Which get an unnecessarily bad rap from people who don't work primarily in JS; there are cases when callbacks get awkward, but just looking at code that's four levels of indent deep and declaring it "callback hell" -- as you so frequently see -- is a super-shallow analysis. That code is clean and easy to understand, as often as not.)

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

#24

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, b…

[deleted]

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

#25
post #7

I've used ES6 and prefer coffeescript - IMHO more concise, easier to read, and has been place for years.

Yup. It's as if coffeescript was created by one person (and a bunch of great PRs!), while ES6 came out of a committee.

That's exactly what I like about ES6 (the fact that it has come out of a committee and is now a standard).

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

#26
post #6

Earlier quoted context omitted.

What exactly did you have in mind other than "new Promise()" to create a promise?

new Promise(function(resolve, reject){ /* code */ }) it's a little much

Ideally, if you're writing business logic, you shouldn't be creating promises but consuming/combining/chaining them from libraries.

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

#27
post #24

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, b…

[deleted]

> .then() does not create a new promise

The docs for Promise say that then() returns a promise. Are you saying it returns the original promise (ie. this)?

> But if your call to then isn't a Promise or a function that returns a Promise, your chain ends.

I don't think this is correct. The docs show examples of chains of then() calls where the intermediate function isn't returning a promise. See "chaining": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

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

#28
post #24

I've just been playing with Promises and like them a lot. But one thing I find strange is that ".then()" creates a new promise, but with no way to reject it. ie. I can't write: return new Promise((resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. }).then((step1Val, resolve, reject) => { // Do some stuff, call resolve()/reject() on success/failure. // But this doesn't actually work, b…

[deleted]

> .then() does not create a new Promise

It returns a promise, right?

  > var foo = Promise.resolve([1,2,3]).then(function() { return 5 })
  > foo
  

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

#29
post #13
post #5

Wow. I can't believe template strings ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... ) aren't in this list. I'm incredibly excited to start having those at my disposal.

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…

> for things like templating.

I'm excited for not having external libraries to handle string interpolation.

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

#30

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.

`class` trades the flexibility of prototypes for the familiarity of other languages. :(
Post reply on HN