node/doc/api
Lance Ball ad8257fa5b repl: Assignment of _ allowed with warning
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>
2016-03-18 21:03:40 +01:00
..
_toc.markdown deps: update v8 to 4.4.63.9 2015-08-04 11:56:14 -07:00
addons.markdown doc: fix typo in api/addons 2016-03-14 08:48:08 -07:00
all.markdown deps: update v8 to 4.4.63.9 2015-08-04 11:56:14 -07:00
assert.markdown doc: mention prototype check in deepStrictEqual() 2016-02-23 09:17:11 -05:00
buffer.markdown doc: fix return value of write methods 2016-03-16 12:40:19 -07:00
child_process.markdown doc: Add note about use of JSON.stringify() 2016-03-15 09:38:28 -07:00
cluster.markdown doc: add missing property in cluster example 2016-02-27 14:04:51 +01:00
console.markdown console: check that stderr is writable 2016-03-15 19:10:55 -07:00
crypto.markdown doc: fix typo in synchronous randomBytes example 2016-03-18 10:54:21 -07:00
debugger.markdown doc: replace function expressions with arrows 2016-01-27 23:00:20 +01:00
dgram.markdown doc: fix typo in api/dgram 2016-03-14 08:48:03 -07:00
dns.markdown doc: fix dns.resolveCname description typo 2016-03-10 02:16:36 +01:00
documentation.markdown doc: add info to docs on how to submit docs patch 2016-03-07 11:25:15 -08:00
domain.markdown doc: fix type references for link gen, link css 2016-02-09 13:12:21 +01:00
errors.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
events.markdown events: add eventNames() method 2016-03-15 09:25:35 -07:00
fs.markdown doc: fix typo in api/fs 2016-03-14 08:47:32 -07:00
globals.markdown doc: proper markdown escaping -> \_\_, \*, \_ 2016-01-22 21:32:50 -08:00
http.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
https.markdown doc: minor improvement to HTTPS doc 2016-02-01 09:14:42 -08:00
index.markdown Remove util.print from docs 2010-11-07 17:22:56 -08:00
modules.markdown doc: require behavior on case-insensitive systems 2016-02-27 14:33:51 +01:00
net.markdown net: emit host in lookup event 2016-03-18 11:04:02 -05:00
os.markdown doc: minor improvement in OS docs 2016-02-04 19:25:07 +01:00
path.markdown path: assert inputs are strings 2016-03-17 23:20:12 -04:00
process.markdown doc: Add note about use of JSON.stringify() 2016-03-15 09:38:28 -07:00
punycode.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
querystring.markdown doc: fix multiline return comments in querystring 2016-03-17 17:15:06 -03:00
readline.markdown doc: don't use "interface" as a variable name 2016-01-30 00:33:14 +01:00
repl.markdown repl: Assignment of _ allowed with warning 2016-03-18 21:03:40 +01:00
stream.markdown doc: clarify when writable.write callback is called 2016-03-14 19:46:49 +02:00
string_decoder.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
synopsis.markdown doc: harmonize $ node command line notation 2016-01-22 19:57:19 +01:00
timers.markdown timers: fail early when callback is not a function 2016-01-04 14:56:19 +11:00
tls.markdown doc: remove non-standard use of hyphens 2016-03-14 08:32:55 -07:00
tty.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
url.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
util.markdown doc: document deprecation of util._extend 2016-03-16 12:55:55 -07:00
v8.markdown doc: update V8 URL 2016-03-02 23:22:29 +01:00
vm.markdown vm: fix produceCachedData 2016-02-21 14:59:35 -05:00
zlib.markdown doc: clarify type of first argument in zlib 2016-03-15 12:09:38 -03:00