_(下划线)变量的赋值


\Assignment of the _ (underscore) variable

版本历史
版本变更
v9.8.0

添加了 _error 支持。

默认情况下,默认求值器会将最近求值的表达式的结果分配给特殊变量 _(下划线)。将 _ 显式设置为一个值将禁用此行为。

\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' 

AltStyle によって変換されたページ (->オリジナル) /