JS 简单继承

简单的继承

function Pet(word) {
	this.word  = word
	this.speak = function () {
		console.log(this.word)
	}
}

function Dog(word) {
	Pet.call(this,word)
    // Pet.apply(this, arguments)
}

var dog = new Dog('汪汪')
dog.speak()
发布了115 篇原创文章 · 获赞 38 · 访问量 43万+

猜你喜欢

转载自blog.csdn.net/wangweiscsdn/article/details/83721956