最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

debugging javascript in Chrome console - Stack Overflow

matteradmin8PV0评论

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?

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?

Share Improve this question asked Sep 24, 2012 at 0:02 BrainLikeADullPencilBrainLikeADullPencil 11.7k24 gold badges82 silver badges138 bronze badges 3
  • 3 it's saying that the same thing is bieng logged 32, 8 and 8 times – jeremy Commented Sep 24, 2012 at 0:03
  • strange because in firebug it's showing a full list of console.log statements. – BrainLikeADullPencil Commented Sep 24, 2012 at 0:06
  • 2 This is a feature, not a bug. It was done by design because it's far easier to see that a single console.log statement was made 87 times by looking at the number to the left while in Firefox, you'd have to try and count. – TMan Commented Sep 24, 2012 at 0:08
Add a ment  | 

2 Answers 2

Reset to default 9

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.

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.

Post a comment

comment list (0)

  1. No comments so far