Proposal: Reflecting on non-string property names
domenic at domenicdenicola.com
Sun Dec 2 14:04:50 PST 2012
> -----Original Message-----
> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Allen Wirfs-Brock
> Sent: Friday, November 30, 2012 19:18
> 1) Object.getOwnPropertyNames and Object.keys remain unchanged. They only return a string property key values.
> 2) Reflect.ownKeys(obj) is a new reflection function that returns an iterator. The iterator produces the keys of all public own properties of the object pass as an argument. This includes both string and Symbol key values.
A minor qualm compared to all the other things being discussed here, but isn't it confusing to have "keys" mean two different things? In ES5 usage it means "enumerable, string-valued" whereas in this proposed Reflect.ownKeys it means "no qualifiers: non-enumerable OK, symbol-valued OK".
From an ES5 perspective, "property names" (as in getOwnPropertyNames) are "enumerable or non-enumerable string-valued" whereas "keys" are "enumerable string-valued." Ideally there would be a new designation for non-string–valued.
More information about the es-discuss