JS 原型模式创建对象
例子:
class Test { constructor(val) { this.val = val } walk() { console.log(this) console.log('walk') } stop(){ console.log('stop') } } let vm = new Test('jike') console.log(vm)
Test.prototype(就是控制台上的__proto__)指向原型对象,Test.prototype,constructor又指向类Test