Blue number in Chrome Dev Console?

前端 未结 2 1044
说谎
说谎 2021-02-19 00:54

In javascript I have a variable that I push to console.log then increment it and push it to the log again, which shows the below in the Chrome Dev Tools.

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-19 01:42

    When you print a string using console.log you get black output. However, if you print a number the output is blue. See the screenshot bellow (don't mind the lines with 'undefined' value as this is what console.log() returns by default).

    console.log() output

    And you are right, your problems with += are somehow connected to these colours. You were adding number to a string which resulted in concatenation (53).

提交回复
热议问题