当前位置:网站首页>05_ Review object defineProperty
05_ Review object defineProperty
2022-07-19 01:36:00 【ID does not exist.】
review Object.defineProperty Method
<body>
<script type="text/javascript" >
let number = 18
let person = {
name:' Zhang San ',
sex:' male ',
}
Object.defineProperty(person,'age',{
// value:18,
// enumerable:true, // Controls whether attributes can be enumerated , The default value is false
// writable:true, // Controls whether attributes can be modified , The default value is false
// configurable:true // Controls whether attributes can be deleted , The default value is false
// When someone reads person Of age Attribute ,get function (getter) It will be called , And the return value is age Value
get(){
console.log(' Someone read age The attribute is ')
return number
},
// When someone modifies person Of age Attribute ,set function (setter) It will be called , And will receive the specific value of the modification
set(value){
console.log(' Someone has modified age attribute , And it's worth it ',value)
number = value
}
})
// console.log(Object.keys(person))
console.log(person)
</script>
</body>边栏推荐
猜你喜欢

Common mode attack and shared prime of RSA

uni-app微信公众号(5)——新增、修改地址

软件漏洞分析入门(五)

记一次用canvas做出腾讯云首页banner流光效果的经历

uni-app微信小程序——商城(4)——商家

The applet is embedded in the web page, jumps to the applet and transmits parameters. The wechat applet realizes the authorization of official account to obtain openid

Express中间件的分类及使用

jsx 编译

红日安全靶场3

自己封装的风格化的开关卡片组件
随机推荐
uni-app微信公众号(1)——网页授权登录
Champ de tir rouge 3
ES6 map extract array object
Uni scroll view pull-down refresh
JS replaces a character in the string, and JS modifies the specified character in the string
E-commerce background management login
无数次踩坑安装AWVS
v-cloak与v-bind绑定class
Nodejs cross domain CORS
今天的码农女孩总结了关于npm包管理和url模块的笔记
时间戳转化时间
Node的数据库编程(MySQL),增删改查
promise
07_事件的基本使用
单页面应用 SPA 和多页面应用 MPA
es可选链
Uni app wechat applet - Mall (4) - merchants
使用leaflet仿原神提瓦特大地图制作日记
v-model原理及修饰符
uni scroll-view 下拉刷新