Last active
December 6, 2021 19:01
-
-
Save rahgurung/146aaa937ce33663c3c4466e30c5bc58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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