JavaScript 语法是什么:{Ci, CC}?
我正在做一些 FF 附加开发,我看到这样的语法:
var {Cc, Ci} = require('chrome');
只是好奇该语法是什么,以及它是否对 FF 开发或其他东西有特殊意义。
I'm doing some FF add-on development and I'm seeing syntax like this:
var {Cc, Ci} = require('chrome');
Just curious what that syntax is and if it's special to FF development or something else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这称为解构赋值。这是 JavaScript 1.7 的一项功能,其中在本文中,“JavaScript”指的是 Mozilla 对 ECMAScript 标准的特定扩展。
它预计包含在下一版本的 JavaScript 中。
等效的 ECMAScript 5 代码是
This is called destructuring assignment. It is a feature of JavaScript 1.7, where in this context "JavaScript" refers to Mozilla's specific extensions to the ECMAScript standard.
It is slated for inclusion in the next version of JavaScript.
The equivalent ECMAScript 5 code would be
请参阅 Domenic 的回答,了解语法是什么,称为解构赋值。下面的答案就是为什么FF附加开发需要这个。
http://groups.google.com/group/mozilla-labs-jetpack/browse_thread/thread/d288b79903b5b434。
简短的回答是肯定的,它是专门针对 Firefox 插件开发的。相关文档可以在 https://addons.mozilla.org/en-US/developers/docs/sdk/1.3/dev-guide/module-development/chrome.html。
See Domenic's answer as to what the syntax is which is called a destructuring assignment. The answer that follows is why this is needed for FF add-on development.
There's a discussion on what this is and why it is needed at http://groups.google.com/group/mozilla-labs-jetpack/browse_thread/thread/d288b79903b5b434.
Short answer is yes, it's specific for Firefox add-on development. The relevant documentation can be found at https://addons.mozilla.org/en-US/developers/docs/sdk/1.3/dev-guide/module-development/chrome.html.