ES6-class

/*
function Person(aaa) {
  this.a = a
}
Person.prototype.b = function () {}
等价
class Person {
  constructor(a) {
    this.a = a
  }
  b() {
  }
}
*/
class Person {
  constructor(a) {
    this.a = a
  }

  b() {
  }
}

Person.prototype.c = ""

let p1 = new Person()
//判断该属性是原型上的还是自己的
console.log(p1.hasOwnProperty("c"))
//判断对象是否存在该属性
console.log("c" in p1)

/*
继承
class Student extends Person{
  constructor() {
    super();
  }
}
*/
原文地址:https://www.cnblogs.com/linding/p/14718882.html