Let's consider the following input in terminal
✗ node
Welcome to Node.js v13.1.0.
Type ".help" for more information.
> let a = 13
undefined
> {} + a.toString()
13
> // but
undefined
> let b = {} + a.toString()
undefined
> b
'[object Object]13'
The question is why when you evaluate {} + a.toString()
REPL will show a digit 13, but when you assign it to a variable it equals to the expected string '[object Object]13'
?
This behaviour happens at least in the V8 (Node and Chrome).