es6增加class关键字

class Student{
constructor(name1){
this.name1=name1
}

fav(){
return this.name1
}
}

let s=new Student('li')
console.log(s.fav())

class语法糖根本上还是原型

function Student(name1){
this.name1=name1
}
Student.prototype.fav=function(){
return this.name1
}

静态

class Student {

static fav() {
return 'abc'
}
}

console.log(Student.fav())

继承

class Person{
eat(){console.log('eee')}
}

class Student extends Person {}

new Student().eat()