function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()
function Animal() {
this.name = ‘cat’
this.msg = {
age: 9
}
}
Animal.prototype.greet = function () {
console.log(‘hehe’)
}
function Dog() {
this.name = ‘dog’
}
Dog.prototype = new Animal() //核心一步
const a = new Dog()
a.msg.age = ‘99’
const b = new Animal()