const obj = {
get foo (){
},
set foo (){
}
}
var descript = Object.getOwnPropertyDescriptor(obj,'a');
console.log(descript);
// console.log(descript.get.name) // get foo
// console.log(descript.set.name) // set foo
// 'use strict'
var obj = {
a: 2
};
console.log(Object.getOwnPropertyDescriptor(obj,'a'));
/**
* configurable
* enumerable
* writable
* value
*/
// 对象常量 :不可修改,不可删除 configurable: false writable: false
// preventExtensions 阻止拓展
var test = Object.preventExtensions(obj);
obj.b = 2;// 严格模式下obj.b 就会报错
console.log(test === obj) // true
console.log(Object.isExtensible(obj))// false 不可拓展 true 可拓展