Le 11/04/2011 21:47, Brendan Eich a écrit :
> 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?
Could static analysis help out to detect that the object is not going to
be used and consequently avoid the allocation?

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to