Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get last return value

In nodeJS terminal, I can enter this expression and have as a return 'true':

> var x = true; x;
true

How can I capture this return value in a variable, without changing the expression?

The following is not working:

> var y = (var x = true; x)
SyntaxError: Unexpected token var
like image 591
simon.denel Avatar asked Dec 05 '22 22:12

simon.denel


1 Answers

In node REPL, you can just use _ :

> var x = true; x;
true
> var y = _
undefined
> y
true
like image 176
Denys Séguret Avatar answered Dec 08 '22 11:12

Denys Séguret