Created
November 1, 2012 00:41
-
-
Save romeoh/3990917 to your computer and use it in GitHub Desktop.
apply, call
This file contains hidden or 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
<script type="text/javascript"> | |
function Car(_name, _size){ | |
this.name = _name; | |
this.size = _size; | |
} | |
// call | |
function renterCarCall(_name, _size){ | |
Car.call(this, _name, _size); | |
} | |
var myCar = new renterCarCall("ben", "bigger"); | |
console.log(myCar); | |
// apply | |
function renterCarApply(_car){ | |
Car.apply(this, _car); | |
} | |
var myCar = new renterCarApply(["tico", "small"]); | |
console.log(myCar); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment