I discovered the following behavior in the 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, the _ will be the function reference:
$ node
> () => _
[Function]
> _
[Function]
> _.toString()
'() => _'
Why is this happening?
After calling toString() on the _ variable, the _ is converted into string:
> _
'() => _'
I tried to use _ => () and we have the same issue:
$ node
> _ => {}
[Function]
> _
[Function]
> _.toString()
'_ => {}'
> _
'_ => {}'
I'm using node v5.6.0. This is not reproducible in a file but only in the NodeJS shell.