> 对象是一个特殊的数组,所以新增或修改属性时可以使用数组的方式进行操作
~~~
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)
~~~