属性检测 In,hasOwnPreperty()和propertyIsEnumerable()
2014-10-23 10:10
435 查看
IN 左侧是属性名;右侧是对象名, 如果 属性是 自有属性 或者继承属性 则返回 TRUE
var o={x:1,y:2}
"x" in o 返回 true;
hasOwnProperty() 用来检测对象的属性 是否是 自有属性。
var o={x:1};
o.hasOwnProperty("x") 返回 true
o.hasOwnProperty("tostring") 返回 false。
propertyIsEnumerable() 检测 是自有属性 且为枚举类型的时候 才返回 true。
var o={x:1,y:2}
"x" in o 返回 true;
hasOwnProperty() 用来检测对象的属性 是否是 自有属性。
var o={x:1};
o.hasOwnProperty("x") 返回 true
o.hasOwnProperty("tostring") 返回 false。
propertyIsEnumerable() 检测 是自有属性 且为枚举类型的时候 才返回 true。
相关文章推荐
- hasOwnProperty,Object.keys(),propertyIsEnumerable,for-in(loop)
- javascript 对象及原型继承有关的属性:constructor、prototype、isPrototypeOf、instanceof、in 、hasOwnProperty 等等
- javascript 对象及原型继承有关的属性:constructor、prototype、isPrototypeOf、instanceof、in 、hasOwnProperty 等等
- javascript的创建对象object.create()和属性检测hasOwnPrototype()和propertyIsEnumerable()
- JS中isPrototypeOf 和hasOwnProperty 的区别 ------- js使用in和hasOwnProperty获取对象属性的区别
- 面向对象的程序设计(二)理解各种方法和属性typeof、instanceof、constructor、prototype、__proto__、isPrototypeOf、hasOwnProperty
- for in语句中hasOwnProperty过滤原型属性
- javascript instanceof、isPrototypeOf、hasOwnProperty、in的使用
- js属性对象的propertyIsEnumerable方法
- 理解js的几个关键问题(1):全局变量new和关于hasOwnPropery和PropertyIsEnumerable 等
- JS中的hasOwnProperty()、propertyIsEnumerable()和isPrototypeOf()
- 详谈js使用in和hasOwnProperty获取对象属性的区别
- JS中的hasOwnProperty()和isPrototypeOf()属性实例详解
- js使用in和hasOwnProperty获取对象属性的区别
- javascript中的hasOwnProperty()、propertyIsEnumerable()和isPrototypeOf()
- constructor、prototype、isPrototypeOf、instanceof、in 、hasOwnProperty
- hasOwnProperty检测属性
- 浅谈js使用in和hasOwnProperty获取对象属性的区别
- hasOwnProperty和isPrototypeOf
- There is no READABLE property named 'id' in class 'java.lang.Integer'