什么是“小于点"?Chrome控制台输出中的符号意味着什么?

2022-01-11 00:00:00 console google-chrome javascript

有时,但并非总是如此,当 Chrome JavaScript 控制台中的评估结果导致未定义"时,左边距中有一个看起来像带点的小于号的符号.

Sometimes, but not always, when the result of an evaluation in the Chrome JavaScript console results in "undefined", there is a symbol in the left margin that looks like a less-than symbol with a dot.

示例可以在 Chrome 开发者工具文档的这一部分.

但该符号的含义似乎从未得到解释.有人知道它想表达什么吗?谢谢.

But what that symbol means does not appear to ever be explained. Does anybody know what it's trying to convey? Thanks.

推荐答案

每当命令行运行一组函数时,控制台输出的最后一行总是输入中最后一个操作的返回值.当命令执行开始后有控制台输出时,该符号调用函数的返回值.这是为了避免在这种情况下产生混淆:

Whenever a set of function runs on the command line, the last line of console output is always the returned value of the last operation in the input. The symbol calls out the return value of a function when there has been console output since the start of the command execution. This is to avoid confusion in a case like this:

function logVar(someVar) {
    console.log(someVar);
}

当你在控制台运行logVar时,它会输出someVar的值.然而,logVar 的返回值也会被记录下来(这里是 undefined).将返回值与记录的变量在视觉上区分开来是很有帮助的,因此您不必查看输出的最后一行并想知道为什么我的变量 undefined?".

When you run logVar on the console, it outputs the value of someVar. However, the return value of logVar is also logged (here, undefined). It's helpful to have the return value visually distinguished from the logged variable, so you don't look at the last line of the output and wonder, "Why is my variable undefined?".

相关文章