Skip to content

Instantly share code, notes, and snippets.

@romeoh
Created November 1, 2012 00:41
Show Gist options
  • Save romeoh/3990917 to your computer and use it in GitHub Desktop.
Save romeoh/3990917 to your computer and use it in GitHub Desktop.
apply, call
<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