Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's your favorite new ES2015 feature and why? #3

Closed
arthurvr opened this issue Nov 6, 2015 · 2 comments
Closed

What's your favorite new ES2015 feature and why? #3

arthurvr opened this issue Nov 6, 2015 · 2 comments

Comments

@arthurvr
Copy link

arthurvr commented Nov 6, 2015

No description provided.

@vadimdemedes
Copy link
Owner

Generator functions and only generator functions.

For me, it is the only new feature that really improves the way I write code every day. Yes, arrow functions are nice, yes, classes are nice, but we could do all the same things before, right? Generator functions allow us to do things, that were not possible before!

Generators alone don't give much benefit, but if you use them with co and koa - Oh. My. God.

I've never had so much pleasure writing JavaScript before. It's just beautiful:

let post = yield Post.findOne();
post.title = 'New title';
yield post.save();

I know it's unofficial way of using generators, but with ES7 async/await, all we have to do is to switch function * myFn () to async myFn () and yield myFn() to await myFn() and we are golden.

@arthurvr
Copy link
Author

arthurvr commented Nov 6, 2015

Thanks for the answer! :)

@arthurvr arthurvr closed this as completed Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants