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

Spread Operator Syntax for Objects #74

Open
jameshbush opened this issue Jun 16, 2019 · 3 comments
Open

Spread Operator Syntax for Objects #74

jameshbush opened this issue Jun 16, 2019 · 3 comments

Comments

@jameshbush
Copy link
Contributor

This section suggests the Spread Operator syntax only works for iterable object literals. In fact, generic Object literal declarations also support spread operator assignment syntax:

"Note that the spread operator isn’t limited to arrays and arguments. The spread operator can be used with any iterable object. Iterable is a protocol in ES6 that allows you to turn any object into something that can be iterated over. We’ll research the iterable protocol in Iteration and Flow Control."

Screen Shot 2019-06-16 at 09 41 20

Is there another section where non-iterable Object Literal spread syntax is covered?

@ljharb
Copy link
Contributor

ljharb commented Jun 16, 2019

Object spread wasn’t part of the language until ES2018; and it applies to any object, iterable or not (mst objects aren’t iterable, including your two examples)

@jameshbush
Copy link
Contributor Author

Thanks for the explanation @ljharb

I'm missing a lot of context about the evolution ofJavaScript. This book is a great asset to the community. Thanks.

@bevacqua
Copy link
Member

We could add a note that clarifies this for future readers? @jajajames want to PR that up? 🎉

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

3 participants