Why are results of methods / statements that use
global._
reassigning_
?
_
holds the value of the last evaluated statement:
> 'foo'
'foo'
> _
'foo'
> var http = require('http');
undefined
> _
undefined
Thus, it's not the use of _
that changes _
, it's doing anything that changes _
. It is initially undeclared because there is no previous statement.
After accessing other global properties like require, why is
_
's value set to undefined rather than a[Circular]
?
The only reason you see [Circular]
in your first example is because _
has just been set equal to global
(because global
is the last evaluated statement), so global._
circularly refers back to global
. In the case of your assignment statement with require
, the line yields undefined
, so that's the value that gets placed in _
.