javascript - Unexpected token on spread operator in Chrome? - Stack Overflow

I was testing something in my Chrome dev tools with the following code:const one = {a: "a", b

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 anonanon
Add a ment  | 

2 Answers 2

Reset to default 5

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.

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信