javascript Reflect对象

本文深入解析JavaScript中的Reflect API,涵盖Reflect.ownKeys、String.fromCharCode、Reflect.apply、Reflect.construct、Reflect.defineProperty、Reflect.deleteProperty、Reflect.get、Reflect.getOwnPropertyDescriptor及Reflect.getPrototypeOf等方法的使用与功能,为前端开发者提供全面的技术指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Reflect.ownKeys()  //获取key-value中的key

String.fromCharCode()  //返回数字对应的字符

Reflect.apply(String.fromCharCode,undefined,code_list)  //等同于String.fromCharCode(...code_list)

Reflect.construct(Array,[7]) //等价于new Array(7)

Reflect.construct(Date,[])  //等价于new Date()  当前日期

Reflect.construct(Number,[111])  //等价于new Number(111)

Reflect.defineProperty(obj,'name',{value:'Alex',writable:true,enumerable:true,configurable:true})  //返回true;若是Object.defineProperty则返回{name:"Alex"}

Reflect.deleteProperty() //删除特定属性  等价于delete inventory.apple 删除成功均返回true

Reflect.get()  //获取特定对象  如Reflect.get(inventory,'grapefruit')

Reflect.getOwnPropertyDescriptor() //返回特定对象的特定属性的描述器

Reflect.getPrototypeOf() //返回特定对象的原型(prototype)

PS:

       unshift  在前端新增元素      shift()  在前端删除元素

  push  在后端新增元素       pop() 在后端删除元素

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值