当前位置:网站首页>Object.defineProperty和Reflect.defineProperty的容错问题
Object.defineProperty和Reflect.defineProperty的容错问题
2022-06-24 19:28:00 【aliven1】
- Object.defineProperty,出现错误,会阻断线程,容错处理需要大量使用try…catch
- Reflect.defineProperty,可以通过Reflect.defineProperty调用结果的布尔值,直接处理容错分支
let obj = {
a:1,b:2}
//通过Object.defineProperty去操作
//#region
/* try { Object.defineProperty(obj,'c',{ get(){ return 3 } }) Object.defineProperty(obj,'c',{ get(){ return 4 } }) } catch (error) { console.log(error) } */
//#endregion
//通过Reflect.defineProperty去操作
//#region
/* const x1 = Reflect.defineProperty(obj,'c',{ get(){ return 3 } }) console.log(x1) const x2 = Reflect.defineProperty(obj,'c',{ get(){ return 4 } }) if(x2){ console.log('某某某操作成功了!') }else{ console.log('某某某操作失败了!') } */
//#endregion
// console.log('@@@')
边栏推荐
- [product design and R & D collaboration tool] Shanghai daoning provides you with blue lake introduction, download, trial and tutorial
- Volcano成Spark默认batch调度器
- how to install clustershell
- 2022国际女性工程师日:戴森设计大奖彰显女性设计实力
- What does CTO (technical director) usually do?
- 图的邻接表存储 数组实现
- Multi view function in blender
- TCP_ Nodelay and TCP_ CORK
- 去掉录屏提醒(七牛云demo)
- TDengine可通过数据同步工具 DataX读写
猜你喜欢

LeetCode-513. 找树左下角的值

OSI and tcp/ip model

EditText controls the soft keyboard to search

架构实战营 第 6 期 毕业设计

Shengzhe technology AI intelligent drowning prevention service launched

应用实践 | 海量数据,秒级分析!Flink+Doris 构建实时数仓方案

memcached全面剖析–5. memcached的应用和兼容程序

Intelligent fish tank control system based on STM32 under Internet of things

Network layer & IP

Wireshark packet capturing skills summarized by myself
随机推荐
Apple mobile phone can see some fun ways to install IPA package
VSCode无网环境快速迁移开发环境(VIP典藏版)
Auto. JS to automatically authorize screen capture permission
Vscode netless environment rapid migration development environment (VIP collection version)
01---两列波在相遇处发生干涉的条件
升哲科技 AI 智能防溺水服务上线
SYSCALL_ Define5 setsockopt code flow
Understanding openstack network
Blender's landscape
字节的软件测试盆友们你们可以跳槽了,这还是你们心心念念的字节吗?
TCP specifies the source port
使用 Go 编程语言 66 个陷阱:Golang 开发者的陷阱和常见错误指北
Volcano成Spark默认batch调度器
Memcached comprehensive analysis – 3 Deletion mechanism and development direction of memcached
The most important thing at present
[camera Foundation (I)] working principle and overall structure of camera
关于Unity中的transform.InverseTransformPoint, transform.InverseTransofrmDirection
Auto. JS to realize automatic unlocking screen
传输层 udp && tcp
【Camera基础(二)】摄像头驱动原理和开发&&V4L2子系统驱动架构