coffeehoock
4/19/2017 - 5:34 PM

js_extends

js_extends

var Animal = function(name) {
	this.name = name || "new Animal" ;
}

// auto add parametrs
Animal.prototype = {
	numberLimbs: 4,
	headCount  : 1,
	libs       : 33
};

// var ani = new Animal("utka");




var Cat = function() {
	this.isCat = true;
};

// extends class Animal
Cat.prototype = new Animal();




var cat = new Cat();

// является ли cat дочерним от класса Cat
console.log(cat instanceof Cat)    // true
console.log(cat instanceof Animal) // true Animal  являеться наследником класса Object
console.log(cat instanceof Object) // true Object --> Animal -> Cat
console.log(cat instanceof String) // false