最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

debugging javascript in Chrome console - Stack Overflow

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论