07/24/2016
NodeSummit 2016







06/15/2014
Node REPL

Node REPL

06/15/2014
Tweet about this blog entry:

Intended Audience: Hip Noobie

New to Node JS and still working via file processing? This can get really tedious if you’re like me and would like to experiment on the fly. Well, there’s a nice little utility in Node that implements a REPL (read-eval-print loop)! If you’ve ever accidentally typed “node”, at your command, without specifying your script file to run, then you’ve taken yourself–inadvertently, albeit–to Node’s REPL interface. The default prompt is simply a greater-than sign, “>”.

Here, you can type in Javascript expressions and blocks of code, just like you would in a script file. The result is whatever the expression returns. Type, “x = 2” and you’ll get back “2”. Type, “var x = 2”, and you’ll get back undefined, because a declaration doesn’t evaluate to anything when executed. But, now that it’s buffered, you can type “x” and get back the value, i.e. “2”.

Here’s a little hint, type “.help” to get a list of commands for the REPL interface as implemented by default.

Feel free to go through the Node.js docs to get more details.


Tweet about this blog entry:

Comments/Discussion