Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Node.js repl from printing output

If the result of some javascript calculation is an array of 10,000 elements, the Node.js repl prints this out. How do I prevent it from doing so?

Thanks

like image 266
Nick Avatar asked Dec 03 '12 12:12

Nick


People also ask

What is the command to stop REPL in node JS?

To exit the REPL, you can type . exit , or press CTRL+D once, or press CTRL+C twice, which will return you to the shell prompt.

How do you exit the node js REPL Read eval print loop )?

Press Ctrl+C to terminate the current command. Pressing Ctrl + C twice causes the REPL to quit. Press Ctrl+D to exit the REPL. Pressing up and down arrow keys you can see command history and modify previous commands.

What is REPL in node JS eval print loop all of these?

REPL stands for Read Eval Print Loop and it represents a computer environment like a Windows console or Unix/Linux shell where a command is entered and the system responds with an output in an interactive mode. Node.js or Node comes bundled with a REPL environment.

How do I get out of node REPL?

To exit from the REPL terminal, press Ctrl + C twice or write . exit and press Enter.


2 Answers

Why don't you just append ; null; to your expression?

As in

new Array(10000); null;

which prints

null

or even shorter, use ;0;

like image 177
akuhn Avatar answered Sep 22 '22 05:09

akuhn


Assign the result to a variable declared with var. var statements always return undefined.

> new Array(10)
[ , , , , , , , , ,  ]

> var a = new Array(10)
undefined
like image 45
JohnnyHK Avatar answered Sep 22 '22 05:09

JohnnyHK