构造函数创建对象方法
var student=new Object()
// 特征
student.name = "阿宝🤗"
student.age = "16"
// 行为
student.draw = function(){
console.log(this.name+"会干饭")
}
console.log(student)
字面量的方式创建对象
var teacher = {}//创建没有属性和方法的对象
teacher.name = "校花"
teacher.age = "20"
teacher.teac =function (){
console.log(this.name+"人见人爱,花见花开的美男子")
}
console.log(teacher)
对象字面量
var laoJie={ //直接在大括号里创建属性
name:"臭宝",
age:18,
sing:function(){
console.log(this.name+"爱干饭!!!")
}
}
console.log(laoJie)