Skip to content

Instantly share code, notes, and snippets.

@furkanacaryes
Created January 9, 2020 12:29
Show Gist options
  • Save furkanacaryes/c150fe8d727ff848d844dd45bc1754d5 to your computer and use it in GitHub Desktop.
Save furkanacaryes/c150fe8d727ff848d844dd45bc1754d5 to your computer and use it in GitHub Desktop.
Binding `this`
const external = function(sample) {
if (!!sample) this.beCool('I AM COOL!');
}
class Cool {
beCool(msg) {
console.log(msg);
}
run() {
external.bind(this, true)()
}
}
const instance = new Cool();
instance.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment