Created
June 1, 2016 13:09
-
-
Save j8/9ff43deeccf06b500dea617ee868c53f to your computer and use it in GitHub Desktop.
Node.js interview question for process.nextTrick(fn);
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
'use strict' | |
var c=0; | |
function fn() { | |
if(c++<100000000) { | |
console.log('done 2', c, process.memoryUsage().heapUsed) | |
// return fn() // will crash | |
return process.nextTick(fn); //works | |
} | |
console.log('done'); | |
} | |
fn() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment