Last active
August 29, 2015 14:02
-
-
Save ety001/8c0d19ae0405b01d589d to your computer and use it in GitHub Desktop.
JS apply call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Person = function(name,age){ | |
this.name = name; | |
this.age = age; | |
} | |
var Print = function(){ | |
this.functionName = 'Print'; | |
this.show = function(){ | |
var msg = []; | |
for(var key in this){ | |
if(typeof(this[key])!='function'){ | |
msg.push([key,':',this[key]].join('')); | |
} | |
} | |
console.log(msg.join(' ')); | |
} | |
} | |
var Student2 = function(name,age,school,grade){ | |
Person.apply(this,arguments); | |
Print.apply(this,arguments); | |
console.log(this); | |
this.school = school; | |
this.grade = grade; | |
} | |
var s = new Student2('Jim',22,'Harvard',2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment