-
Notifications
You must be signed in to change notification settings - Fork 463
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
Feature request: Spread syntax support in object literals #401
Comments
kinda leaning against at moment ...
let foo = { aa: 1, bb: 2 };
let bar = { bb: 3 };
// below feels like a bug-in-waiting
// where user needs to worry about property orderings:
console.log({ ...foo, ...bar, cc: 4 });
// { aa: 1, bb: 3, cc: 4 }
console.log({ ...bar, ...foo, cc: 4 });
// { aa: 1, bb: 2, cc: 4 } Using similar
|
Just to add another point to your considerations: between Object.assign and the spread syntax, the former mutates the first argument, whereas the latter not. |
yep, hence the empty |
What am I missing here, what's the point of these examples here? console.log({ ...foo, ...bar, cc: 4 });
// { aa: 1, bb: 3, cc: 4 }
console.log({ ...bar, ...foo, cc: 4 });
// { aa: 1, bb: 2, cc: 4 }
console.log(Object.assign({}, foo, bar, { cc: 4 }));
// { aa: 1, bb: 3, cc: 4 }
console.log(Object.assign({}, bar, foo, { cc: 4 }));
// { aa: 1, bb: 2, cc: 4 } Isn't this supposed to show some difference? Or am I totally on the wrong path here? |
Is your feature request related to a problem? Please describe.
It looks like the spread syntax in object literals is not supported in JSLint, possibly because when "how javascript works" was written wasn't still part of the ECMAScript standard.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
example:
Describe the solution you'd like
Are there any possibilities to support spread syntax? Or there are good reasons to avoid it?
The text was updated successfully, but these errors were encountered: