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.
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.
So basically why, in the Chrome Dev Console, would a number show up in blue?
Highest score (default)
It is white space. For example you have a container with 100% of width and two divs inside, one of those with 50% and another width 40% of width, it means that there is 10% of space empty... this 10% would be shown in this purple dashed line area by the Google inspector.
Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console. On MacOS you can use Command + K button.
Open Chrome, press Ctrl+Shift+j and it opens the JavaScript console where you can write and test your code.
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).
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
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With