2014-03-07 0:51 GMT+01:00 C. Scott Ananian <ecmascr...@cscott.net>: > On Thu, Mar 6, 2014 at 6:31 PM, André Bargull <andre.barg...@udo.edu> > wrote: > > On 3/6/2014 11:35 PM, Andrea Giammarchi wrote: > > The proposed [[GetOwnPropertyNames]] internal method is supposed to be a > > more restrictive version of [[OwnPropertyKeys]] to ensure Proxy objects > > don't lie about their properties. > > [[SafeOwnPropertyKeys]] or [[CheckedOwnPropertyKeys]] seems like a > more accurate and less confusing name, since it returns keys not > names. >
The result is only "checked" for proxies, but the name of internal methods should make sense for all types of objects. >From an API point of view, the more significant difference may be that [[OwnPropertyKeys]] returns an iterable, while [[CheckedOwnPropertyKeys]] would return an array of strings and symbols. I don't think there is currently a good naming convention to distinguish things that return an iterable versus things that return an array. I searched the spec for all clients of [[OwnPropertyKeys]], they are: Object.assign(target, source) // to iterate over all own props (strings and symbols) of source Object.keys(O) // to construct array of strings (of enumerable properties) Reflect.ownKeys(O) // to get iterator over strings and symbols // the following should be reliable primitives, thus should use the "checked" version that returns an array: Object.getOwnPropertyNames(O) // to construct array of strings Object.getOwnPropertySymbols(O) // to construct array of symbols Object.{freeze,seal}(O) // to reliably redefine all own props Object.{isFrozen,isSealed}(O) // to reliably test all own props Given that most of the functions that use [[OwnPropertyKeys]] need to either construct an array anyway, or want reliable results, I wonder whether we shouldn't just change [[OwnPropertyKeys]] to include the checks and return an array instead of an iterable. That way we avoid having two internal methods that do more or less the same thing. Cheers, Tom
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss