process can be accessed from anywhere in the node. It contains the information about the currently running node thread. it is also a inherited class of EventEmitter
properties:
version, platform, uptime, arch, title, memoryUsage, pid .......
streams:
stdin, stdout, stderr
stdin is a really useful device for interprocess communication. It’s used to facilitate things such as piping in the shell.
nextTick()
First it evaluates all the code, which includes outputting 'End of 1st loop'. Then it calls the callbacks on nextTick()
process.on('uncaughtException', function(e) {
console.log(e);
});
process.nextTick(function() {
console.log('tick');
});
process.nextTick(function() {
iAmAMistake();
console.log('tock');
});
process.nextTick(function() {
console.log('tick tock');
});
console.log('End of 1st loop');
output:
End of 1st loop
tick
[ReferenceError: iAmAMistake is not defined]
tick tock
Command Line Arguments
process.argv
// print process.argv
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});