Skip to content

Instantly share code, notes, and snippets.

@smks
Created December 5, 2016 16:24
Show Gist options
  • Save smks/84e2a8c6fdf4488077857f0477c9e927 to your computer and use it in GitHub Desktop.
Save smks/84e2a8c6fdf4488077857f0477c9e927 to your computer and use it in GitHub Desktop.
const batman = {firstName: 'Bruce', lastName: 'Wayne'};
const superman = {firstName: 'Clark', lastName: 'Kent'};
function speak(quote, location) {
console.log(this);
console.log(this.firstName + ' ' + this.lastName + ' ' + 'says ' + quote + ' from ' + location);
};
// Apply for Array
speak.apply(batman, ["'It's not who I am underneath, but what I do that defines me'", "Gotham City"]);
speak.apply(superman, ["'Dreams save us. Dreams lift us up and transform us'", "Metropolis"]);
// Call for Comma
speak.call(batman, "'It's not who I am underneath, but what I do that defines me'", "Gotham City");
speak.call(superman, "'Dreams save us. Dreams lift us up and transform us'", "Metropolis");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment