Skip to content

Instantly share code, notes, and snippets.

@tankala
Created August 5, 2018 15:12
Show Gist options
  • Save tankala/9aed5d09d04a9edfd944a8a2ae4456c5 to your computer and use it in GitHub Desktop.
Save tankala/9aed5d09d04a9edfd944a8a2ae4456c5 to your computer and use it in GitHub Desktop.
How to pass a Variable or Argument to a callback function in Node.js
var mainFunction = function(callback) {
//Did something
console.log("In Main Function");
callback();
}
var callbackFunction = function() {
console.log('Variable: ' + this.variable);
console.log("In Callback Function");
}
mainFunction(callbackFunction.bind({"variable": "Variable"}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment