Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Node.js console.clear() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The console.clear() method is used to clear the stdout, when stdout is a TTY (Teletype) i.e. terminal it will attempt to clear the TTY. When stdout is not a TTY, this method does nothing.

The console.clear() will work differently across different operating systems and terminal types. For Linux operating systems, console.clear() operates like the clear shell command in terminal. On Windows, console.clear() will clear the current terminal viewport for the Node.js binary.



Parameters: This method does not accept any parameters.

Below programs illustrate the console.clear() method in Node.js:

In this example, first we write the node.js command in the terminal and start node.js and then write basic command

After console.clear(), the terminal will cleared same like the clear command do in the terminal

To exit Node.js terminal press Ctrl + C two times or use .exit command.


// Node.js program to demonstrate the  
// Buffer.clear() Method
// Both two lines will not display
// the result on screen
console.log("A computer science portal");
// Clear the previous screen
// Display the content
console.log("Clear the console screen");



My Personal Notes arrow_drop_up
Last Updated : 13 Oct, 2021
Like Article
Save Article
Similar Reads
Related Tutorials