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.
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.
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;
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.