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?
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?
Share Improve this question asked Apr 24, 2017 at 17:48 anonanon2 Answers
Reset to default 5You 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.
Now spreading the Object is supported in ES6
const one = {a: "a", b: "b"};
const two = { ...one, c: "c" };
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744831486a4596109.html
评论列表(0条)