I want to be sure I understand something.
let a = {};
a[0] = "foo"; //coerces 0 to "0" before assigning the property
but [[Get]]
from 9.1.8 in the spec looks like this:
function get(p, receiver) {
return ordinaryGet(this, p, receiver);
}
function ordinaryGet(o, p, receiver) {
if (!isPropertyKey) throw new TypeError("InvalidKey");
...
}
function isPropertyKey(key) {
return ["string", "symbol"].contains(typeof(key));
}
Where exactly does the type coercion happen? Seems like a number type should fail isPropertyKey
.