Object characteristics: 1. writable: writable let obj = {age:10} obj.age = 1 // Reassign the property console.log(obj.age) //1 2. enumerable: enumerable The let obj = {name:"zhang", age:20, sex:"male"} let newObj = Object.create(obj) newObj.height = 200 for(p in newObj){ console.log(p,"->", newObj[p]) } Output:
3. Configurable: Configurable let obj = {name:"jim"} delete obj.name // After deletion, the property will no longer exist console.log(obj.name) //undefined The above three properties of the object's own attributes are true by default. If you want to modify the default values of these characteristics, you can use
let obj = {name:"zhang", age:20, sex:"male"} Object.defineProperty(obj, "sex", {writable:false}) obj.sex = "female" console.log(obj.sex) // Male After setting This is the end of this article about the three property characteristics of javascript objects. For more relevant content on javascript object property characteristics, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Hide div in HTML Hide table TABLE or DIV content css style
>>: Design: A willful designer
In many apps and websites, when we log in or regi...
The role of virtual DOM First of all, we need to ...
In the field of data analysis, database is our go...
Problem Description I created three virtual machi...
The solution to the problem that Ubuntu 18.04 in ...
MySQL is a relational database management system ...
Usage scenario: We use Alibaba Cloud and purchase...
Table of contents View Disk Usage Disk Cleanup (D...
This article mainly introduces the installation/st...
The relevant person in charge of Baidu Input Metho...
Table of contents 1. Define object methods 2. Def...
Install mysql under win10 1. Download MySQL from ...
When using CSS pseudo-elements to control element...
When installing nginx, mysql, tomcat and other se...
Mysql8.0.12 decompression version installation me...