Can I use node.js as a REPL shell?

javascript, node.js, read-eval-print-loop

Solution

You can do so. However, those expressions do not have a return value so node prints `undefined`.

> var x = 'abc'
undefined
> function f() {}
undefined
> f
[Function: f]
> x
'abc'
>

Problem

This is a noob question. I am trying to use `node.js` as a `JavaScript` REPL (read-evaluate-print loop) shell to work with JavaScript interactively. Unfortunately I can define neither variables nor functions. ``` > var x = 'abc' undefined > function f() {} undefined > ``` What can I do to use `node.js` as a REPL shell? P.S. I know I can probably use Rhino Shell but I would prefer `node`.

Original source