jeudi 25 décembre 2014

Can you explain this JavaScript syntax (variable extrapolation)?


I just saw something I have never seen before and cannot seem to find an explanation of what it really is... not in the ES5.1 standard and ES6 draft, nor in the Mozilla ES6 support.


Please explain technically what is happening (anonymous object, anonymous block?) and provide some reference to a section in the ES standard or some other resource that explains this.


The context is a firefox extension.



const // var also works here it seems
{
classes : Cc
, interfaces : Ci
, utils : Cu

} = Components


It creates variables Cc, Ci, Cu on the current scope. It's kind of counter intuitive since this looks like an anonymous object, but then one would expect property names on the left and values on the right...


Source of the construct in question: http://ift.tt/1CJGI75





Aucun commentaire:

Enregistrer un commentaire