Home > Web Front-end > JS Tutorial > Js method to dynamically add and delete object properties

Js method to dynamically add and delete object properties

一个新手
Release: 2017-09-21 10:52:46
Original
2235 people have browsed it

var obj = {} 或  var obj = new Object()
//1.对象.属性 = 赋值
obj.aaa = 1
//2.对象[属性] = 赋值  
obj["aaa"] = 1;
方法2中的属性可以为变量,例如
var a = "aaa";
obj[a] = 1;
====================  删除
delete obj.aaa
delete obj["aaa"]
Copy after login

The above is the detailed content of Js method to dynamically add and delete object properties. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template