mirror of
https://github.com/nodejs/node.git
synced 2025-05-14 18:26:05 +00:00
![]() This commit addresses https://github.com/nodejs/node/issues/5431 by changing the way that the repl handles assignment to the global _ variable. Prior to this commit, node sets the result of the last expression evaluated in the repl to `_`. This causes problems for users of underscore, lodash and other packages where it is common to assign `_` to the package, e.g. `_ = require('lodash');`. Changes in this commit now result in the following behavior. - If unassigned on the repl, `_` continues to refer to the last evaluated expression. - If assigned, the default behavior of assigning `_` to the last evaluated expression is disabled, and `_` now references whatever value was explicitly set. A warning is issued on the repl - 'expression assignment to _ now disabled'. - If `_` is assigned multiple times, the warning is only displayed once. - When `.clear` is executed in the repl, `_` continues to refer to its most recent value, whatever that is (this is per existing behavior). If `_` had been explicitly set prior to `.clear` it will not change again with the evaluation of the next expression. PR-URL: https://github.com/nodejs/node/pull/5535 Fixes: https://github.com/nodejs/node/issues/5431 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> |
||
---|---|---|
.. | ||
_toc.markdown | ||
addons.markdown | ||
all.markdown | ||
assert.markdown | ||
buffer.markdown | ||
child_process.markdown | ||
cluster.markdown | ||
console.markdown | ||
crypto.markdown | ||
debugger.markdown | ||
dgram.markdown | ||
dns.markdown | ||
documentation.markdown | ||
domain.markdown | ||
errors.markdown | ||
events.markdown | ||
fs.markdown | ||
globals.markdown | ||
http.markdown | ||
https.markdown | ||
index.markdown | ||
modules.markdown | ||
net.markdown | ||
os.markdown | ||
path.markdown | ||
process.markdown | ||
punycode.markdown | ||
querystring.markdown | ||
readline.markdown | ||
repl.markdown | ||
stream.markdown | ||
string_decoder.markdown | ||
synopsis.markdown | ||
timers.markdown | ||
tls.markdown | ||
tty.markdown | ||
url.markdown | ||
util.markdown | ||
v8.markdown | ||
vm.markdown | ||
zlib.markdown |