some notes

Destructure This!

Neil Mix is excited about generators and the potential for threading in Javascript 1.7 (Firefox 2). Being a single-threaded kind of guy, I'm excited about destructuring assignment:
function size(img){
let w = img.width;
let h = img.height;
return [w, h];
}
[width, height] = size($('image25'));
The size() function returns two vars in an array, with are immediately assigned to scalar variables width and height.

Seems simple, why am I excited? Because it *is* simple, and we haven't been able to do it gracefully before.

By Chris Snyder on February 19, 2007 at 10:33am

jump to top