Skip to content

Instantly share code, notes, and snippets.

@j8
Created June 1, 2016 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j8/9ff43deeccf06b500dea617ee868c53f to your computer and use it in GitHub Desktop.
Save j8/9ff43deeccf06b500dea617ee868c53f to your computer and use it in GitHub Desktop.
Node.js interview question for process.nextTrick(fn);
'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