Suggest, right)

Michał Wadas michalwadas at
Mon Sep 19 09:03:24 UTC 2016

On Mon, Sep 19, 2016 at 7:32 AM, Park Hyeonu <nemo1275 at> wrote:

> I'm sure this feature is already implemented for every modern js engines,
> as it's needed to implement Map/Set.

But you know that, it's indeterministic and implementation is free to
reorganize pointers?

a = {}; b = {};,b); // 1
gc.enforceGC();,b); // -1

So any userland structure can't rely on persistence of order.

Moreover, such ordering can be implemented with WeakMap.

const wm = new WeakMap()
let i = 0;
function getId(obj) {
    if (!wm.has(obj))
        wm.set(obj, i++);
    return wm.get(obj);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list