C/C++教程

【学习打卡】第6天 ES(6-11)全版本语法-对象扩展:Object.values(),Object.entries()

本文主要是介绍【学习打卡】第6天 ES(6-11)全版本语法-对象扩展:Object.values(),Object.entries(),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  • 课程名称: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基础,希望能够坚持下去。

这篇关于【学习打卡】第6天 ES(6-11)全版本语法-对象扩展:Object.values(),Object.entries()的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!