The code copy is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
/*
* Use . to add attributes to the object
Use keyword delete to delete attributes
Add attributes with []
The difference between
r.name==r["name"];
r.name can only add string attributes
[]Add attributes, powerful function, you can add attributes dynamically
*/
var r=new Object();
alert(typeof(r));
//Add attributes
r.name="jobs";
alert(r.name);
r.getname=function(){
return "jobs";
}
alert(r.getname());
//Delete attribute
delete r.name;
alert(r.name);//The result at this time is undefined
//-----------------------------------------------------------------------------------------------------------------------------
//Add attributes to the object using brackets
r["name"]="tom";
alert(r["name"]);
r.name="toms";
alert(r["names"]);
//r.name==r["name"]//These two ways of writing are equivalent
var arg="abc";
r[arg]="heima";// Powerful, you can add properties dynamically, and make a string returned by a function variable
r.arg="itcast";//arg is a string by default
</script>
</head>
<body>
</body>
</html>