>> for (k in keys(o)) ...
>> for (v in values(o)) ...
>> for ([k, v] in properties(o)) ...
>
> What are "keys", "values", and "properties" here? Global functions?
Those are API's suggested in the strawman:iterators proposal. They would be
importable from a standard module.
> How would a new object abstraction T customize them just for instances of T?
By writing its own custom iteration protocol via proxies with the iterate()
trap implemented appropriately. E.g.:
function MyCollection() { }
MyCollection.prototype = {
iterator: function() {
var self = this;
return Proxy.create({
iterate: function() { ... self ... },
...
});
}
}
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss