What's the “less than dot” symbol mean in Chrome console output?

前端 未结 1 1331
借酒劲吻你
借酒劲吻你 2021-01-05 10:49

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

1条回答
  •  日久生厌
    2021-01-05 11:29

    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);
    }
    

    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?".

    0 讨论(0)
提交回复
热议问题