#9 ✓resolved
John-David Dalton

Create hasOwnProperty equiv

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


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];
    };
  }
}

Comments and changes to this ticket

  • John-David Dalton

    John-David Dalton February 6th, 2009 @ 01:27 PM

    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".

  • 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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

JavaScript frameworks share similar features and functionality such as DOM manipulation, event registration, and CSS selector engines. FuseJS attempts to incorporate the strengths of these frameworks into one stable, efficient, and optimized core JavaScript framework.

People watching this ticket

Pages