- Explain why do we want sometimes to use
setImmediate
instead of usingsetTimeout
? - Explain the difference between
process.nextTick
andsetImmediate
? - Name 10 core modules that Node provides by default, and 10 of the Global objects?
Write a function in Node factorial(n)
to find asynchronously the factorial of a number. Write your observation (CPU, RAM.. etc) on what happens in Node Process
when we calculate the factorial of a large number.
- factorial(3) is 3 * factorial(2)
- factorial(2) is 2 * factorial(1)
- factorial(1) is 1 * factorial(0)
- factorial(0) is 1
// your Node code here...
console.log('start');
factorial(3).then(console.log);
console.log('end');
// Test your code in Node.JS CLI, Output:
// start
// end
// 6