Skip to content

Numeric keys larger than 2**24 - 2*20 + 1 are given as the empty string #87

@bakkot

Description

@bakkot

Consider the following program:

let obj = {
  [2**24 - 2**20]: 0,
};

let obj2 = {
  [2**24 - 2**20 + 1]: 0,
};


function isEmptyKey(thing) {
  let keys = Reflect.ownKeys(thing);
  if (keys.length !== 1) throw 'too many keys';
  console.log(keys[0] === '');
}

isEmptyKey(obj);
isEmptyKey(obj2);

This prints false, true. In every other engine, and per the spec, it should be false, false. (No one ever hits the error path; that's just for illustration.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions