Yes. You can evaluate simple expressions using Node REPL.
Yes, it is possible to evaluate simple expressions using the Node.js REPL (Read-Eval-Print Loop). REPL stands for Read-Eval-Print Loop, and it allows you to interactively run JavaScript code. You can evaluate expressions, declare variables, define functions, and execute JavaScript statements directly in the Node.js REPL environment.
For example, if you open your terminal or command prompt and type node
to start the Node.js REPL, you can then type simple expressions such as mathematical calculations like addition, subtraction, multiplication, and division. Here’s an example session:
$ node
> 2 + 2
4
> 5 * 6
30
> Math.sqrt(16)
4
> 'Hello, ' + 'world!'
'Hello, world!'
In this session, we evaluated simple expressions such as addition (2 + 2
), multiplication (5 * 6
), square root (Math.sqrt(16)
), and string concatenation ('Hello, ' + 'world!'
). The REPL promptly prints the result of each expression after you press Enter.