Created
August 5, 2018 15:12
-
-
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
This file contains hidden or 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 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