Chrome开发者控制台中的蓝色数字? [英] Blue number in Chrome Dev Console?

查看:1011
本文介绍了Chrome开发者控制台中的蓝色数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在javascript中我有一个变量,我推送到 console.log 然后递增它并再次将其推送到日志,这在Chrome开发工具中显示如下。

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.

这个变量已经做了一些怪异的事情,比如如果我尝试使用 + = 运算符添加它,它实际上将增加的值放在数字(例如,如果 x = 5 ,我做了 x + = 3 x 等于 53 )。真正令人难以置信的一点是,用++增加它可以按预期工作,但我的问题不是为什么会发生这种情况,而是为什么增加的数字在控制台中是蓝色的?如果有人能告诉我上述情况发生的可能情况会很好,但我感觉控制台中的蓝色条目与它有关。

This variable has done some freaky stuff, like if I try to use the += operator to add to it, it actually puts the added value after the number (for example if x=5 and I did x+=3, x would equal 53). The really boggling part of this is that incrementing it with ++ works as expected, but my question isn't why that's happening but rather why the incremented number is blue in the console? If anyone could tell me possible cases where the above would happen that'd be great, but I have a feeling the blue entry in the console is related to it.

所以基本上,为什么在Chrome开发者控制台中,数字会显示为蓝色?

So basically why, in the Chrome Dev Console, would a number show up in blue?

推荐答案

使用<$打印字符串时c $ c> console.log 你得到黑色输出。但是,如果打印数字,则输出为蓝色。请参阅下面的屏幕截图(不要介意具有'undefined'值的行,因为这是 console.log()默认返回的内容。)

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).

你是对的, + = 的问题以某种方式连接到这些颜色。您正在为字符串添加数字,导致连接( 53 )。

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).

这篇关于Chrome开发者控制台中的蓝色数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆