Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Create hasOwnProperty equiv

#9

Fuse.ownsProperty = function(object, property) {
  return object.hasOwnProperty(propery);
};
 
if (typeof Object.prototype.hasOwnProperty !== 'function') {
  if ([]['__proto__'] === Array.prototype) {
    Fuse.ownsProperty = function(object, property) {
      var result, proto = object['__proto__'];
      object['__proto__'] = null;
      result = property in object;
      object['__proto__'] = proto;
      return result;
    };
  } else {
    Fuse.ownsProperty = function(object, property)
      return object.constructor.prototype[property] !== object[property];
    };
  }
}

Reported by John-David Dalton · February 5th, 2009 @ 11:19 AM

State: resolved
Milestone: none
Assigned to: John-David Dalton John-David Dalton

Activity

  1. John-David Dalton
    John-David Dalton

    3.1 Draft

    
    4.3.29   "Own Property"  An own property of an object is a property that is directly present on that object. 
    
    4.3.30   "Inherited Property"  An inherited property is a property of an object that is not one of its own properties
             but is a property (either own or inherited) of the object’s prototype. 
    

    2.62 spec

    
    ... First the object mentioned directly is examined for such a property; if that object contains the named property,
    that is the property to which the reference refers; if that object does not contain the named property, the prototype
    for that object is examined next; and so on.
    

    isOwnProperty()

    containsProperty()

    isDirectProperty()

    isOwnProperty() is close to hasOwnProperty(), but according to spec 3.1, isOwnProperty is probably more correct because its a type of property "Own Property" vs "Inherited Property".

    February 6th, 2009 @ 01:27 PM

  2. John-David Dalton

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.