继承可以使子类有父类的属性和方法。
类 能产生对象的东西。
function Human(name){
this.name = name
}
Human.prototype.run = function(){
console.log("我叫"+this.name+",我在跑")
return undefined
}
function Man(name){
Human.call(this, name)
this.gender = '男'
}
// Man.__proto__ = Human.prototype
var f = function(){}
f.prototype = Human.prototype
Man.prototype = new f()
Man.prototype.fight = function(){
console.log('糊你熊脸')
}
class A{
constructor(){
}
}
网友评论