3 ms·
Many of these are at stage 3 of the standardization process and have a good chance of shipping soon: https://github.com/tc39/proposal-iterator-helpers https://g
by ameliaquining 2y ago
Many of these are at stage 3 of the standardization process and have a good chance of shipping soon: https://github.com/tc39/proposal-iterator-helpers https://github.com/tc39/proposal-iterator-helpers
(They're not on objects, which I think is probably for the best; every method on Object.prototype is a shadowing risk and so we're unlikely to see any besides the ones that already exist. You can always use Object.entries; if your object has so many dynamically-computed properties that eagerly collecting them is a performance concern, then it should probably be a Map.)
- nobleach 2y agoAgreed. But there's nothing precluding someone from implementing Symbol.iterator on Object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Not saying anyone SHOULD do this... just that one _could_.
- derefr 2y ago> if your object has so many dynamically-computed properties that eagerly collecting them is a performance concern, then it should probably be a Map Should be, but there's so much legacy code that is going to hand you objects. Also, unless you go to a weirdly large amount of effort, JSON.parse will give you objects.
- tracker1 2y agoEven then... [Object] could just iterate [k,v] unless the behavior is overridden... even then that's probably appropriate for something like weakmap anyhow.
- cdaringe 2y agoThats a nice set of improvements! Thx for the ref On the proto extension: Sure. Fair argument. Id still be interested in a world where theyre there and non enumerable, or there but behind an .iter() field.