Skip to content

Instantly share code, notes, and snippets.

@moiz-frost
Created September 7, 2019 19:53
Show Gist options
  • Save moiz-frost/e73a116f6feff43bdc05d967bc2b0443 to your computer and use it in GitHub Desktop.
Save moiz-frost/e73a116f6feff43bdc05d967bc2b0443 to your computer and use it in GitHub Desktop.
call()
function printHP() {
console.log(this);
}
var car = {
year: '2010',
make: 'Honda',
color: 'White',
transmission: 'Manual',
horsePower: 140,
topSpeed: 120,
printHP: printHP
}
printHP(); // prints the global object
printHP.call(car); // prints the car object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment