The hasOwnProperty function method in JavaScript returns a Boolean value indicating whether an object has a property with the specified name.
Usage:
object.hasOwnProperty(proName)
The parameter object is required. An instance of an object.
proName is required. A string value for the property name.
If the object has a property with the specified name, the hasOwnProperty function method in JavaScript returns true; otherwise, it returns false. This method cannot check whether the property is in the object's prototype chain; the property must be a member of the object itself. In the following example, all String objects share a common split method. The code below will output false and true.
var s = new String("JScript");
print(s.hasOwnProperty("split"));
print(String.prototype.hasOwnProperty("split"));