Skip to content

Instantly share code, notes, and snippets.

@silent-lad
Last active March 15, 2019 18:08
Show Gist options
  • Save silent-lad/671100888972592cdcb5478716e80e05 to your computer and use it in GitHub Desktop.
Save silent-lad/671100888972592cdcb5478716e80e05 to your computer and use it in GitHub Desktop.
function Preposition(name_init) {
this.name = name_init;
this.displayName = function() {
console.log(`Preposition is ${this.name}`);
}
}
let these = new Preposition("these");
these.displayName(); // Prints Preposition is these
let those = new Preposition("those");
those.displayName(); // Prints Preposition is those
let thoseDisplay = these.displayName.bind(those); // Creates new function with value of “this” equals to "those" object
thoseDisplay(); // Prints:- Preposition is those
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment