gpt4 book ai didi

javascript - Chrome 中传播运算符的意外标记?

转载 作者:行者123 更新时间:2023-11-30 07:54:31 25 4
gpt4 key购买 nike

我正在使用以下代码在我的 Chrome 开发工具中测试一些东西:

const one = {a: "a", b: "b"};
const two = { ...one, c: "c" };
VM417:1 Uncaught SyntaxError: Unexpected token ...

为什么我在传播运算符上会出现此错误?

最佳答案

您正在尝试 Object rest/spread ,它还没有完全进入 ES6 规范。因此,目前还不支持传播到一个对象中,只能传播到一个数组中。

对象休息/传播目前是第 3 阶段提案。

关于javascript - Chrome 中传播运算符的意外标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43594687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com