process.exit([code])
It
exits the process synchronously with an exit status of code.
console.log("Hello World"); console.log("Welcome to node.js programming"); /* * If you do not pass exit code, exit uses either the 'success' code 0 or the * value of process.exitCode if it has been set */ process.exit(); console.log("This message do not print");
Output
Hello
World
Welcome
to node.js programming
Adding a listener on
process exit
/*
Adding a listener on process exit */
process.on("exit",
function() {
console.log("Exit initialted by
application");
});
/* Adding a listener on process exit */ process.on("exit", function() { console.log("Exit initiated by application"); }); console.log("Hello World"); console.log("Welcome to node.js programming"); /* * If you do not pass exit code, exit uses either the 'success' code 0 or the * value of process.exitCode if it has been set */ process.exit(); console.log("This message do not print");
Output
Hello
World
Welcome
to node.js programming
Exit
initiated by application
No comments:
Post a Comment