Node.js process.stdout Property
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
// Node.js program to demonstrate the // process.stdout Property // Printing process.stdout property value 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
// Node.js program to demonstrate the // process.stdout Property // For process.std.out // Association is not possible process.stdout.write( "Beginner" ); process.stdout.write( "for" ); process.stdout.write( "Beginner" ); |
Run the index.js file using the following command:
node index.js
Output:
w3wiki