Called on an object instance, accepts a string as argument. If the object has a property with the name contained in the string argument, and that property is enumerable, it returns true
. Otherwise it returns false
.
在对象实例上调用,接受字符串作为参数。 如果对象具有名称包含在字符串参数中的属性,并且该属性是可枚举的,则它将返回true
。 否则返回false
。
Example:
例:
const person = { name: 'Fred' }
Object.defineProperty(person, 'age', {
value: 87,
enumerable: false
})
person.propertyIsEnumerable('name') //true
person.propertyIsEnumerable('age') //false
翻译自: https://flaviocopes.com/javascript-object-prototype-propertyisenumerable/