問題描述
有時,但并非總是如此,當 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
?".
這篇關于什么是“小于點"?Chrome控制臺輸出中的符號意味著什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!