当前位置:网站首页>54-Object. Defineproperty method
54-Object. Defineproperty method
2022-07-20 08:41:00 【longfei815】
54-Object.defineProperty Method
// obj.name = 'Vue'
// It can be used to set properties for objects
// Object.defineProperty( Object name to add attribute , Property name , Some property settings )
<!DOCTYPE html>
<html lang="en">
<head>
<title>54-Object.defineProperty Method </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
let obj = {
age:7
}
// obj.name = 'Vue'
// It can be used to set properties for objects
// Object.defineProperty( Object name to add attribute , Property name , Some property settings )
Object.defineProperty(obj,'name',{
value:'vue',
writable:true, // Set up obj Of name Properties can be modified , If not set , The default is false, Cannot be modified .
configurable:true, // Set up obj Of name Properties can be deleted , If not set , The default is false, Can't be deleted .
enumerable:true, // Set up obj Of name Properties can be traversed , The default value is false Cannot be traversed .
});
console.log(obj);
obj.name = 'Vue3';
console.log(obj);
// delete obj.name // Delete object obj Of name attribute .
// console.log(obj);
for(key in obj){
console.log(key);
}
</script>
</head>
<body>
</body>
</html>
边栏推荐
- Mise en œuvre du carnet d'adresses en langage C
- 2022-07-18 第五小组 修身课 学习笔记(every day)
- 枚举(enum)奇妙的使用、联合体(共用体union)对空间节省的巧妙
- Sanziqi (n-ziqi) C language programming, super detailed explanation
- 通过调试发现程序死循环的原因
- Chapter 62: blue screen crash when running vs program on win10
- 轻松掌握|C语言字符串与内存的相关库函数|
- Pointer operation exercises and string functions
- Learning diary 4- program structure and control statements
- 结构体专题
猜你喜欢
随机推荐
60-[重点]Object.defineProperty的set方法
c语言指针重难点
8.事件处理——事件修饰符
100-京东导航栏-插槽使用-弹性布局(display: flex;)
原生JS完美实现深拷贝
My first blog
steam文件夹移动后游戏需要重新安装怎么办
Sanziqi (n-ziqi) C language programming, super detailed explanation
节流阀中的 flag=false if(flag){return} timer=null if(timer){return} 写法一直不太明白怎么起作用的
指针数组和数组指针有什么区别?
5. Two ways of writing el and data
数组合并方法:concat( )
Learning diary 4- program structure and control statements
学习日记1
66-[重点]v-for指令的key属性
Space saving "bit segments" in C language“
【js】call()、apply()、bind() 的用法
Recursive backtracking - maze walking
[learning notes] operation summary of "STL speech contest process management system"
Chapter 62: blue screen crash when running vs program on win10