概念
类就是就是对某一个类具体实例(对象)的抽象 动物是类
对象是类中的具体实例 猫是对象
function Student(name,age){
this.name = name;
this.age = age;
} //Student是类 chen、zhang是对象
var chen = new Student("陈文",18);
var zhang = new Student("张三",18)
/* this指实例化的对象 */
console.log(chen)//{name: "陈文", age: 18}
console.log(zhang)//{name: "张三", age: 18}
读取对象的属性
function Person(name,age){
this.name = name;
this.age = age;
}
var p = new Person("cheng",18);
console.log(p.age)//18