> 對象是一個特殊的數組,所以新增或修改屬性時可以使用數組的方式進行操作
~~~
var person = new Object();
var person = {
firstName:"Jony",
lastName:"J",
fullName: function(){
return this.firstName + ' ' + this.lastName
}
};
// 新增屬性的兩種方式
person.newProp1 = "this is new1";
person['newProp2'] = "this is new2";
console.log("名稱1:" + person.firstName)
console.log("名稱2:" + person['lastName'])
console.log("全稱:" + person.fullName())
// 獲取屬性的兩種方式
console.log("新增屬性1:" + person['newProp1'])
console.log("新增屬性2:" + person.newProp2)
~~~