Live data from Hacker News

ES6 Overview in Bullet Points

github.com

1–10 of 50 posts

Re: ES6 Overview in Bullet Points

#3
Looking good and informative, but to be honest I am really interested in use cases. I think I understand how to use generators but I have no idea where I could use them in real-world scenarios. Same goes for WeakMaps, Proxies... Anyone care to give some examples?

Re: ES6 Overview in Bullet Points

#4
Great writeup. I welcome most of the additions, but I somehow cannot get behind things like:

var {foo} = pony is equivalent to var foo = pony.foo var {foo: baz} = pony is equivalent to var baz = pony.foo

I am not sure why, but most languages get into a state where they seem to encourage non-readable code. What was wrong with 'var baz = pony.foo' to start with?

Re: ES6 Overview in Bullet Points

#5
post #3

Looking good and informative, but to be honest I am really interested in use cases. I think I understand how to use generators but I have no idea where I could use them in real-world scenarios. Same goes for WeakMaps, Proxies... Anyone care to give some examples?

checkout Koa to see a great use case of generators. By yielding to asychronous code (instead of callbacks) you can write JS that looks like it's synchronous.

Re: ES6 Overview in Bullet Points

#6
This is awesome, but can I just say foo/bar/baz drives me nuts. How about `{outerProperty: {innerProperty: 'innerValue'}}` ? That just seems so much easier to follow to me, especially in these deep-nested destructuring examples.

But anyway, seriously, this is awesome. The author is responsible for a large part of my ES6 knowledge.

Re: ES6 Overview in Bullet Points

#7
post #4

Great writeup. I welcome most of the additions, but I somehow cannot get behind things like: var {foo} = pony is equivalent to var foo = pony.foo var {foo: baz} = pony is equivalent to var baz = pony.foo I am not sure why, but most languages get into a state where they seem to encourage non-readable code. What was wrong with 'var baz = pony.foo' to start with?

the core use case is

  var { foo } = pony
I agree this is kind of silly in isolation, but more often than not, its used like this:

  var { foo, bar, baz } = pony
which is honestly not that hard to read, and is much better than

  var foo = pony.foo;
  var bar = pony.bar;
  var baz = pony.baz;
which is very useful when you're referencing properties of pony a lot. Since you're going to see destructuring used like

  var { foo, bar, baz } = pony
typically, I think its a very nice idea to always do your variable assignments like that even when its a little obtuse. I'd rather not see multiple styles for variable assignment.

  var { foo: f } = pony
is just there as an escape hatch in case foo already exists in the namespace. It is not something you would typically do.

Re: ES6 Overview in Bullet Points

#8
post #4

Great writeup. I welcome most of the additions, but I somehow cannot get behind things like: var {foo} = pony is equivalent to var foo = pony.foo var {foo: baz} = pony is equivalent to var baz = pony.foo I am not sure why, but most languages get into a state where they seem to encourage non-readable code. What was wrong with 'var baz = pony.foo' to start with?

I find it most useful for import statements:

import {Button, Text} from 'react-native';

and in function declarations:

function f({foo, bar})

Re: ES6 Overview in Bullet Points

#9
post #3

Looking good and informative, but to be honest I am really interested in use cases. I think I understand how to use generators but I have no idea where I could use them in real-world scenarios. Same goes for WeakMaps, Proxies... Anyone care to give some examples?

Check out http://jlongster.com/A-Study-on-Solving-Callbacks-with-JavaS... and the follow up post. It's easy enough to start using generators alongside your existing async solution (callbacks or promises).

Proxies can be used for data-binding, similar to Object.observe.

I've also yet to find a case where I need WeakMaps instead of an Object or Map. All the benefits seem to be a bit too theoretical, but I likely haven't dug into it hard enough.

Re: ES6 Overview in Bullet Points

#10
post #7
post #4

Great writeup. I welcome most of the additions, but I somehow cannot get behind things like: var {foo} = pony is equivalent to var foo = pony.foo var {foo: baz} = pony is equivalent to var baz = pony.foo I am not sure why, but most languages get into a state where they seem to encourage non-readable code. What was wrong with 'var baz = pony.foo' to start with?

the core use case is var { foo } = pony I agree this is kind of silly in isolation, but more often than not, its used like this: var { foo, bar, baz } = pony which is honestly not that hard to read, and is much better than var foo = pony.foo; var bar = pony.bar; var baz = pony.baz; which is very useful when you're referencing properties of pony a lot. Since you're going to see destructuring used like var { foo, bar,…

I wish they'd let you return stuff this way, like:

    return {a, b, c} = foo;
Post reply on HN