Node.js process.stdout Property
Last Updated :
01 Jun, 2021
The process.stdout property is an inbuilt application programming interface of the process module which is used to send data out of our program. A Writable Stream to stdout. It implements a write() method.
Syntax:
process.stdout.write()
Return Value: This property continuously prints the information as the data being retrieved and doesn’t add a new line.
Parameters: This property takes only single strings as an argument.
Note:
- It only takes strings as arguments. Any other data type passed as a parameter will throw a TypeError.
- It can be useful for printing patterns as it does not add a new line.
- We can not write more than one string.
- We can not make associations.
Below examples illustrate the use of process.stdout property in Node.js:
Example 1: Create a JavaScript file and name this file as index.js.
Javascript
process.stdout.write( 'Greetings of the day' );
|
Run the index.js file using the following command:
node index.js
Output:
Greetings of the day
Example 2: Create a JavaScript file and name this file as index.js.
Javascript
process.stdout.write( "Geeks" );
process.stdout.write( "for" );
process.stdout.write( "Geeks" );
|
Run the index.js file using the following command:
node index.js
Output:
GeeksforGeeks
Share your thoughts in the comments
Please Login to comment...