BrainLikeADullPencil
BrainLikeADullPencil

Reputation: 11653

debugging javascript in Chrome console

I inserted quite a few console.log(); statements in a javascript program (written by someone else) and went to view the results in Chrome console. You'll see from the image in this post that three of the lines have numbers inside of them (32, 8, and 8). Those numbers are not clickable. The console is only showing a few of the console.log statements, so I'm guessing those numbers are referring in some way to the other statements not displayed. This is the first time that I've seen that happen, although I've done this same thing before (inserted a lot of console.log statements).

1) does the fact that it's not showing all the console log statements mean something significant? 2) is there some way to understand what those numbers mean, and why they're shown?

enter image description here

Upvotes: 4

Views: 646

Answers (2)

Stu Cox
Stu Cox

Reputation: 4527

Those are repeat occurrences of the same thing being logged, on the same line of code, in quick succession. So you logged it 32 times, then a little later you logged it 8 more times, then 8 more times again.

Upvotes: 3

João Silva
João Silva

Reputation: 91299

Nothing significant. It's just that Google Chrome's console is smart enough to group identical lines and update the counter indicating how many repetitions there were, instead of printing each identical log in a new line.

For example, if you have the following loop:

for (var i = 0; i < 100; i++) {
    console.log("a");
}​

Chrome's console will show a single line with (100) a, whilst others, such as Internet Explorer's Developer Tools, will print a a hundred times.

Upvotes: 9

Related Questions