_(下划线)变量的赋值
【Assignment of the _ (underscore) variable】
默认评估器会将最近评估的表达式结果默认赋值给特殊变量 _(下划线)。显式将 _ 设置为某个值将会禁用此行为。
【The default evaluator will, by default, assign the result of the most recently
evaluated expression to the special variable _ (underscore).
Explicitly setting _ to a value will disable this behavior.】
> [ 'a', 'b', 'c' ]
[ 'a', 'b', 'c' ]
> _.length
3
> _ += 1
Expression assignment to _ now disabled.
4
> 1 + 1
2
> _
4 同样地,_error 将指代最后一次出现的错误(如果有的话)。显式地将 _error 设置为某个值将会禁用此行为。
【Similarly, _error will refer to the last seen error, if there was any.
Explicitly setting _error to a value will disable this behavior.】
> throw new Error('foo');
Uncaught Error: foo
> _error.message
'foo'