crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Node.js Process Example
Question Posted on 15 Feb 2024Home >> Tutorial >> Node.js Tutorial >> Node.js Process Example

Node.js Process Example

Node.js Process Properties Example



To understand this we will take some simple process example to print architecture, pid, platform and version of the process.

File: processexample1.js


console.log(`Process Architecture: ${process.arch}`);
console.log(`Process PID: ${process.pid}`);
console.log(`Process Platform: ${process.platform}`);
console.log(`Process Version: ${process.version}`);




Now open Node.js command prompt and run the below code:-


node processexample1.js






Node.js process

Now will take another process example which is used to print command line arguments. Here node is considered as the first argument, filename is considered as the second argument and actual command line arguments are considered as third, fourth, fifth and so on.

File: processexample2.js


process.argv.forEach((value, index, array) => {
console.log(`${index}: ${value}`);
});




Open Node.js command prompt and run the following code:


node processexample2.js






Node.js process example

Node.js Process Functions



A list of commonly used Node.js process functions are given below.

0
0

FunctionDescription
cwd()returns path of current working directory
hrtime()returns the current high-resolution real time in a [seconds, nanoseconds] array
memoryUsage()returns an object having information of memory usage.
process.kill(pid[, signal])is used to kill the given pid.
uptime()returns the Node.js process uptime in seconds.


.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

Parts of Node.js

Install Node.js Linux

Node.js First Example

Node.js Globals

Node.js DNS






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap