1, isprototypeof
isPrototypeOf is used to determine whether the specified object Object1 exists in a prototype chain of another object Object2, returns True, or false.
The format is as follows:
Object1.isprototypeof (OBJECT2);
Object1 is an example of an object;
Object2 is another object that will check its prototype chain.
A prototype chain can be used to share functionality between different instances of the same object type.
If the OBJECT2 's prototype chain contains Object1, then the isPrototypeOf method returns True.
If Object2 is not an object or Object1 does not appear in the prototype chain in Object2, the isPrototypeOf method returns false.
Examples of use are as follows:
Copy Code code as follows:
var re =/^\s*/;
This defines a regular expression object
Here check regexp is not the prototype chain object of RE, return True
var bisptt = RegExp.prototype.isPrototypeOf (re);
2, hasOwnProperty
hasOwnProperty a property or object that determines whether an object has a name or not, this method cannot check whether the object's prototype chain has the attribute, which must be a member of the object itself.
Returns true if the property or method is defined by the object itself, rather than defined in the prototype chain;
The format is as follows:
Object.hasownproperty (Proname);
Determines whether the name of the Proname is a property or object of the object. Examples of use are as follows:
Copy Code code as follows:
Get false because the properties in the prototype chain cannot be detected
var bStr = "Test String". hasOwnProperty ("split");
This property is inherently on the prototype of a string object and returns True Naturally
var bStr1 = String.prototype.hasOwnProperty ("split");
Returns true because the properties in the prototype are not detected
var bobj = ({fntest:function () {}}). hasOwnProperty ("Fntest");