I am trying to use keys function from underscore in node console as follows
$node
> require('./underscore.js')
...
> _.keys
[Function: keys]
> _.keys
undefined
Why does keys function disapper? Am I missing something here?
The _
is used by Node REPL to store the result of the last expression therefore after your initial call to _.keys
the _
will be referencing the keys
function. To avoid this you need to explicitly use a non-clashing name as a reference to underscore e.g.
$node
> _und = require('./underscore.js')
...
> _und.keys
[Function: keys]
> _und.keys
[Function: keys]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With