On Apr 11, 2011, at 6:36 PM, Allen Wirfs-Brock wrote:
> Personally, I prefer Object.getOwnPropertyDescriptor as a property existence
> test because it doesn't have the reflection the meta-circularity concern. I
> would write Dave's original function as:
>
> function getDefiningObject(obj, key) {
> var obj={}.valueOf.call(obj); // ToObject in case primitive value passed
> while (obj) {
> if (Object.getOwnPropertyDescriptor(obj,key)) return obj;
> obj = Object.getPrototypeOf(obj);
> }
> throw new Error("key " + key + " not found");
> }
Then the only downside is the pd allocation. Any way to avoid that?
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss