标签:key obj 配置 问题 writable let com bash 运算符
再次花时间回顾一下基础,毕竟要想楼建的好,地基就要牢固,嘻嘻!
体验账号2:账号:“123123”。密码:“123123”
- 对象属性的四个特性
- 对象的可扩展性
- 删除属性
- 检测属性
- 枚举属性
- 属性的getter和setter
Object.create()
说明:
const log = console.log;
//返回数据数据的描述
var aa = Object.create({ x: 1 }, {
y: {
value: 1,
writable: false,
enumerable: false,
configurable: true
}
})
log(aa)
log(Object.getOwnPropertyDescriptor(aa,'y'))
delete
说明:
const log = console.log;
//返回数据数据的描述
var aa = {y:2}
Object.defineProperty(aa, 'x', {
value: 1,
writable: true,
enumerable: true,
configurable: false
})
log(aa);
log(delete aa.x);
log(delete aa.y);
log(aa)
in
说明:
const log = console.log;
var aa={x:1};
log('x' in aa);
log('y' in aa);
log('toString' in aa)
hasOwnProperty()
说明:
const log = console.log;
var aa={x:1};
log(aa.hasOwnProperty('x'));
log(aa.hasOwnProperty('y'));
log(aa.hasOwnProperty('toString'))
propertyIsEnumerable()
说明:
const log = console.log;
var aa = { x: 1 };
Object.defineProperty(aa, 'y', {
value: 1,
writable: true,
enumerable: false,
configurable: true
})
log(aa)
log(aa.propertyIsEnumerable('x'));
log(aa.propertyIsEnumerable('y'));
log(aa.propertyIsEnumerable('toString'))
Object.keys()
const log = console.log;
var aa = { x: 1 ,y:2};
Object.defineProperty(aa, 'z', {
value: 3,
writable: true,
enumerable: false,
configurable: true
})
log(aa)
log(Object.keys(aa))
Object.getOwnPropertyNames()
const log = console.log;
var aa = { x: 1 ,y:2};
Object.defineProperty(aa, 'z', {
value: 3,
writable: true,
enumerable: false,
configurable: true
})
log(aa)
log(Object.getOwnPropertyNames(aa))
说明:
const log = console.log;
var aa = { x: 1 ,
get y(){
return 1000;
},
set y(value){
this.x+=value;
}
};
log(aa)
aa.y=1;
log(aa)
标签:key obj 配置 问题 writable let com bash 运算符
原文地址:https://www.cnblogs.com/Juaoie/p/12005768.html