Skip to content

Instantly share code, notes, and snippets.

@bernar83
Created October 26, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernar83/c6ef9fbaf3f108cc90ff07fa0e7ea2bb to your computer and use it in GitHub Desktop.
Save bernar83/c6ef9fbaf3f108cc90ff07fa0e7ea2bb to your computer and use it in GitHub Desktop.
function sayOwnColor() {
console.log(this.color);
}
var red = {
color: 'red',
sayOwnColor: sayOwnColor
};
var blue = {
color: 'blue',
sayOwnColor: sayOwnColor
};
red.sayOwnColor(); // "red"
blue.sayOwnColor(); // "blue"
red.sayOwnColor.call(blue); // "blue"
blue.sayOwnColor.call(red); // "red"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment