This article mainly introduces the application of the hasOwnProperty method in detail. If you need a friend, please refer to it and hope to help you. In JavaScript, The hasOwnProperty function method returns a Boolean value, specifies whether an object has a property with a specified name.
Usage:
Object. hasOwnProperty (proName)
The parameter object is required. An instance of an object.
ProName is required. The string value of an attribute name.
If the object has a property with the specified name, The hasOwnProperty Function Method in JavaScript returns true; otherwise, false. This method cannot check whether the property exists in the prototype chain of the object. The property must be a member of the object. In the following example, all String objects share a common split method. The following code outputs false and true.
Var s = new String ("JScript ");
Print (s. hasOwnProperty ("split "));
Print (String. prototype. hasOwnProperty ("split "));