JavaScript 语法是什么:{Ci, CC}?

发布于 2025-01-04 21:27:20 字数 134 浏览 1 评论 0原文

我正在做一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雄赳赳气昂昂 2025-01-11 21:27:20

这称为解构赋值。这是 JavaScript 1.7 的一项功能,其中在本文中,“JavaScript”指的是 Mozilla 对 ECMAScript 标准的特定扩展。

它预计包含在下一版本的 JavaScript 中

等效的 ECMAScript 5 代码是

var __temp = require('chrome');
var Cc = __temp.Cc;
var Ci = __temp.Ci;

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

var __temp = require('chrome');
var Cc = __temp.Cc;
var Ci = __temp.Ci;
辞取 2025-01-11 21:27:20

请参阅 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文