I found the following behavior in a NodeJS shell:
$ node > function foo () { _ } undefined > _ undefined
Why is the variable _
defined? I expected to get ReferenceError: _ is not defined
.
If I create an arrow function, _
will be a reference to the function:
$ node > () => _ [Function] > _ [Function] > _.toString() '() => _'
Why is this happening?
After calling toString()
in the _
_
variable, it is converted to a string:
> _ '() => _'
I tried using _ => ()
, and we have the same problem:
$ node > _ => {} [Function] > _ [Function] > _.toString() '_ => {}' > _ '_ => {}'
I am using node v5.6.0
. This does not play in the file, but only in the NodeJS shell.
source share