/*
propertyIsEnumerable() is used to detect whether the property belongs Of an object, if detected, return true, otherwise return false.
1. This attribute must belong to the instance and not to the prototype.
2. This attribute must be enumerable, that is, self- The defined attributes can be looped out through for..in.
As long as the above two requirements are met, true will be returned;
*/
function MyObject() {
this.name = " I am a property of the instance";
}
var obj = new MyObject();
alert(obj.propertyIsEnumerable("name"));//true
MyObject.prototype.say = " I am a property of the prototype";
alert(obj.propertyIsEnumerable("say")); //false
for (var i in obj) {
alert(i);//name,age
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn