I remember reading about for-of a while ago, but I didn't know about the destructuring. That's awesome.

miniSphere 5.1.3 - Cell compiler - SSj debugger - thread | on GitHubFor the sake of our continued health I very much hope that Fat Cerberus does not become skilled enough at whatever arcane art it would require to cause computers to spawn enourmous man eating pigs ~Rhuan

This, combined with the Map object they explained, look like super useful additions. the whole (var i = 0; i < blah; i++) deal always felt clunky and overused to me, especially when you don't really need to know the value of i.

Seeing this (especially with destructuring), though, it makes me wish that there was a way for an object to expressly rewrite the data operator, sort of how toString() can be used.

Now that ES6 is out and I've had time to actually play with it, it turns out you can override for-of behavior for any object (of course you probably know this already by now ) - by assigning a generator function to obj[Symbol.iterator]. The generator should yield all the values that for...of must iterate over. For example:

The indirection with [Symbol.iterator] is kind of weird, but overall the methodology isn't too different from a .toString() override.

miniSphere 5.1.3 - Cell compiler - SSj debugger - thread | on GitHubFor the sake of our continued health I very much hope that Fat Cerberus does not become skilled enough at whatever arcane art it would require to cause computers to spawn enourmous man eating pigs ~Rhuan