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
This article describes the example of MySQL sched...
Table of contents 1. Use closures 2. Use ES6 clas...
Configure Mysql master-slave service implementati...
MySQL database storage location: 1. If MySQL uses...
1. Compile proto Create a new proto folder under ...
Preface Semicolons in JavaScript are optional, an...
Introduction to CentOS CentOS is an enterprise-cl...
Table of contents Effect Start creating text Firs...
Installation environment: CAT /etc/os-release Vie...
Flex layout is a commonly used layout method nowa...
Table of contents 1. Project Environment 2. Proje...
1. Add skip-grant-tables to the my.ini file and r...
Table of contents 1. Conditional access attribute...
This example uses jQuery to implement a mouse dra...
Because a certain function of my project requires...