Skip to content

Instantly share code, notes, and snippets.

@imtrinity94
Created March 22, 2023 07:48
Show Gist options
  • Save imtrinity94/5f15114e677c71ecad317b600f15af98 to your computer and use it in GitHub Desktop.
Save imtrinity94/5f15114e677c71ecad317b600f15af98 to your computer and use it in GitHub Desktop.
Function Binding in vRO
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