Created
January 17, 2013 05:13
-
-
Save cjgiridhar/4553831 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
// defining a function | |
var async_factorial = function(n, callback){ | |
console.log("step1"); | |
var fact = 1; | |
process.nextTick(function(){ | |
for(var i=1; i<n; i++) { | |
fact = fact*i; | |
} | |
console.log("step2"); | |
callback(fact); | |
}); | |
}; | |
// using the function | |
async_factorial(50, function(result){ | |
console.log("step3"); | |
console.log("value is:" + result); | |
}); | |
console.log("Out of async"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment