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");
}


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

Reply via email to