obj.name ==> obj["name"]


let obj = {age:18}       
 obj[name] = 16  // ''       
 obj['name'] = 16 //添加属性        
 obj.age = 19; //修改属性        
 console.log(obj)//{age: 19, "": 16, name: 16}


 //变量字符串化
 for (var prop in obj) { 
 	console.log(prop); // prop不再是变量 转化为obj["prop"] 
 }
;
posted @ 2020-01-09 17:39  Mine-  阅读(16)  评论(0编辑  收藏  举报