Created
March 22, 2023 07:48
-
-
Save imtrinity94/5f15114e677c71ecad317b600f15af98 to your computer and use it in GitHub Desktop.
Function Binding in vRO
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
const module = { | |
x: 42, | |
getX: function() { | |
return this.x; | |
} | |
}; | |
const unboundGetX = module.getX; | |
System.log(unboundGetX()); // The function gets invoked at the global scope | |
// expected output: undefined | |
const boundGetX = unboundGetX.bind(module); | |
System.log(boundGetX()); | |
// expected output: 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment