From 274c84b697cd31d6d0173c4c65b052bf545c0e59 Mon Sep 17 00:00:00 2001 From: JavaSDragon <33486797+JavaSDragon@users.noreply.github.com> Date: Mon, 29 Jan 2018 09:26:13 +0300 Subject: [PATCH] Add files via upload --- functionInherit.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 functionInherit.js diff --git a/functionInherit.js b/functionInherit.js new file mode 100644 index 0000000..e91ecf0 --- /dev/null +++ b/functionInherit.js @@ -0,0 +1,29 @@ +function Animal(type, age) { + this.type = type; + this.age = age; + + this.getType = function () { + return console.log('Animal type:' + this.type); + } + this.getAge = function () { + return console.log('Animal age:' + this.age); + } + this.getInfo = function () { + return this.getType() + ' ' + this.getAge(); + } +} +function Cat(type, age, color) { + this.color = color; + Animal.apply(this, arguments); + this.getColor = function () { + return console.log('Animal color:' + this.color); + } + //Animal.call(this); + //this.getInfo=function(){ + //return this.getType()+' '+this.getAge()+' '+this.getColor(); +} +//inherits(Animal,Cat) +// Cat.prototype.getInfo=function(){ +//return this.getType()+' '+this.getAge()+' '+this.getColor(); +var cat1 = new Cat('cat', 2, 'black'); +cat1.getInfo(); \ No newline at end of file