Reputation:
I was testing something in my Chrome dev tools with the following code:
const one = {a: "a", b: "b"};
const two = { ...one, c: "c" };
VM417:1 Uncaught SyntaxError: Unexpected token ...
Why do I get this error on the spread operator?
Upvotes: 3
Views: 3239
Reputation: 361
Now spreading the Object is supported in ES6
const one = {a: "a", b: "b"};
const two = { ...one, c: "c" };
Upvotes: 2
Reputation: 67316
You are attempting Object rest/spread, which has not quite made it into the ES6 specification. So, spreading into an object isn't supported yet, only spreading into an array.
Object rest/spread is currently a Stage 3 proposal.
Upvotes: 5