定义
var obj = {};
obj.a = 'aaa';
obj['1'] = 'bbb';
obj.f1 = function(){
console.log('ff.........');
};
查询属性
// 1. in
console.log('a' in obj);
// 2. hasOwnProperty()
console.log(obj.hasOwnProperty('a'));
删除属性
delete obj.a;
console.log('a' in obj);
console.log(obj.hasOwnProperty('a'));
网友评论