Skip to content

Instantly share code, notes, and snippets.

@rahgurung
Last active December 6, 2021 19:01
Show Gist options
  • Save rahgurung/146aaa937ce33663c3c4466e30c5bc58 to your computer and use it in GitHub Desktop.
Save rahgurung/146aaa937ce33663c3c4466e30c5bc58 to your computer and use it in GitHub Desktop.
var doSomething = (() => this.a);
var a = "From Global";
var Context = {a: 'Hello World!'};
// Use bind to set the `this` context
var x = doSomething.bind(Context);
console.log(x()); // From Global
// Use call to set the `this` context
var y = doSomething.call(Context);
console.log(y); // From Global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment