对象的3种创建方式
1.字面量方式
let obj = {
name:"zhang",
hobby:function(){
console.log('对象方法')
}
}
2.构造函数
let obj = new Object()
obj.name = "zhang"
obj.hobby = function(){
console.log('对象方法')
}
3.Object.create() ;属性方法放在原型上;
let obj = Object.creat({
name:'zhang',
hobby:function(){
console.log('对象方法')
}
})
对象的调用2种方法
// 1种
console.log(obj.name)
// 2种
console.log(obj[name])