课程名称:JavaScript ES(6-11)全版本语法 每个前端都需要的基础课
课程章节: 对象属性描述:Object.getOwnPropertyDescriptors()
主讲老师:谢成
对象属性描述:Object.getOwnPropertyDescriptors(),
Object.getOwnPropertyDescriptors() 所指定对象的所有自身属性的描述符,如果没有任何自身属性,则返回空对象。
const obj = { name: 'imooc', course: 'es' } const desc = Object.getOwnPropertyDescriptors(obj) console.log(desc) const obj = {} Reflect.defineProperty(obj, 'name', { value: 'xiecheng', writable: true, configurable: true, enumerable: false }) Reflect.defineProperty(obj, 'age', { value: 34, writable: true, configurable: true, enumerable: true }) console.log(obj) obj.name = 'zhangsan' console.log(obj) delete obj.name console.log(obj) for(let key in obj){ console.log(key) } console.log(Object.getOwnPropertyDescriptors(obj)) console.log(Object.getOwnPropertyDescriptor(obj, 'age'))
今天学习课程共用了35分钟,重新了解了一下Object.getOwnPropertyDescriptors(),这是我不知道第多少次决心补习JavaScript基础,希望能够坚持下去。