Hacker News new | ask | show | jobs
by mediumdeviation 912 days ago
Actually that only works with Map. For plain objects the key is always the stringified cast of the key.

    > o = { [{}]: 1 }
    { '[object Object]': 1 }
    > k = { toString() { return 'a' } }
    { toString: [Function: toString] }
    > o = { [k]: 1 }
    { a: 1 }
1 comments

Right ... and it seems it's not even possible to simulate object keys using Proxy traps:

  new Proxy(
    {},
    {
      get(target, property) {
        return typeof property
      },
    },
  )[{}] === 'string'