简体   繁体   English

对象分解和剩余参数

[英]Object Destructuring and Rest parameters

I'm using the following syntax and getting an error Unexpected token when babel transpiles my script. 我使用以下语法,并且在babel转译我的脚本时收到错误的Unexpected token But when I run the same script in their 'try it out' online compiler, it runs fine. 但是,当我在他们的“试用”在线编译器中运行相同的脚本时,它运行良好。 What is wrong with my Object Destructuring and or Rest parameters? 我的Object Destructuring和或Rest参数有什么问题?

 function onDestructure({one,two,three,...ten}) { console.log(ten) } 

Rest syntax in object destructuring is not in ES6. ES6中没有对象分解中的Rest语法 You've probably enabled the "experimental" features in the online compiler. 您可能已经启用了在线编译器中的“实验性”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM