admin管理员组文章数量:1302181
I have seen lot of examples in Firefox addon-sdk which uses the below style when declaring a variable.
var { Hotkey } = require("sdk/hotkeys");
What difference it makes with var { Hotkey }
than using var HotKey
? Why the extra flower brackets are used?
I have seen lot of examples in Firefox addon-sdk which uses the below style when declaring a variable.
var { Hotkey } = require("sdk/hotkeys");
What difference it makes with var { Hotkey }
than using var HotKey
? Why the extra flower brackets are used?
- Don't know myself, but this might have some information for you: stackoverflow./questions/4445496/… – CodeMoose Commented Feb 13, 2013 at 7:19
1 Answer
Reset to default 14This is destructuring assignment.
var {Hotkey} = require('sdk/hotkeys');
is equivalent to:
var Hotkey = require('sdk/hotkeys').Hotkey;
See also the harmony:destructuring proposal, which includes the following examples:
// object destructuring
var { op: a, lhs: b, rhs: c } = getASTNode()
// digging deeper into an object
var { op: a, lhs: { op: b }, rhs: c } = getASTNode()
本文标签: firefoxWhy use varVariableName require(3939) in javascriptStack Overflow
版权声明:本文标题:firefox - Why use var { VariableName } = require('') in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741670015a2391545.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论