js 判断对象中是否包含某个属性

var obj = {name:'张三',age:18};
obj.hasOwnProperty('name'); // --> true
obj.hasOwnProperty('id'); // --> false

猜你喜欢

转载自blog.csdn.net/hello_world_1996/article/details/118027280