Why not NodeList#forEach :\?

David Bruant bruant.d at gmail.com
Sun Jun 17 15:40:12 PDT 2012


Le 11/06/2012 19:21, Brandon Benvie a écrit :
> Not quite impossible, you just have to get a bit creative. While
> certainly not as fast as a built in implementation, the method used
> here is still O(1). 
> https://github.com/Benvie/ES6-Harmony-Collections-Shim
After studying the code, my analysis of it is that the complexity of
lookup and insertion in the weakmaps is the complexity of lookup and
insertion of properties in objects.
An implementation which has O(n) for object properties operations will
yield a O(n) for your weakmaps and so on.
But it's very likely that all modern implementations have hashmaps for
that, so indeed O(1)-ish.

For anyone who hasn't read the code yet, I recommand reading it; I found
it very instructive. I particularly enjoyed the "keystore =
Object.create.bind(null, null)".

David




More information about the es-discuss mailing list