PropertyIsEnumerable () is used to check whether a property belongs to an object. If it is detected, true is returned. Otherwise, false is returned. The following describes how to use this property.
The Code is as follows:
/*
PropertyIsEnumerable () is used to detect whether a property belongs to an object. If it is detected, true is returned; otherwise, false is returned.
1. This attribute must belong to the instance and does not belong to the prototype.
2. This property must be enumerable, that is, a custom property, which can be cyclically generated through for... in.
If the preceding two requirements are met, true is returned;
*/
Function MyObject (){
This. name = "I am an instance property ";
}
Var obj = new MyObject ();
Alert (obj. propertyIsEnumerable ("name"); // true
MyObject. prototype. say = "I Am a prototype property ";
Alert (obj. propertyIsEnumerable ("say"); // false
For (var I in obj ){
Alert (I); // name, age
}