编程小贴士

给你的编程提供小点子


一些你不知道的JavaScript Console调试命令

并不是第个人都知道,除了用来记录日志的简单的console.log之外。Console对象还有很多其它有用的功能。我选择了5个最有意思但是还不是那么流行的功能,你马上就可以在你的日常工作中使用。

所以的这些功能在Google Chrome 38中测试通过

console.assert(express, message)

如果传入的第一个参数是false,这个函数就会在当前网页日志中打印出第二条消息。如果表达式为true,就什么也不会打印。

> console.assert(document.querySelector('body'), "缺少 'body' 元素")

> console.assert(document.querySelector('.foo'), "缺少 '.foo' 元素")

[Error] Assertion failed: 缺少 '.foo' 元素

console.table(object)

这个函数会将对象或数据打印成表格

var languages = {
  csharp: { name: "C#", paradigm: "object-oriented" },
  fsharp: { name: "F#", paradigm: "functional" }
};

console.table(languages);

tips1000_2014-11-14_00-13-52

console.profile(name)

这个命令开始对CPU的占用率进行分析。参数是你可以给这个报告起的名字。每运行一次profiler都会保存在下拉列表里保存成独立的分页。记住使用 console.profileEnd()停止分析。

tips1000_2014-11-14_00-13-522

console.group(message)

console.group(message)将此命令后的所有的日志分组到下拉列表,直到调用console.groupEnd()。列表可以被 嵌套。console.groupCollapsed(message) 也可以用。但是创建的列表是自动折(collapse)起来的。

tips1000_2014-11-14_00-13-521

console.time(name)

console.time(name) 会开始一个指定名字以毫秒计时的计时器,它会一直计数直到console.timeEnd(name)被调用。名字与之前相同。

> console.time('Saving user')
> console.log('User saved')
> console.timeEnd('Saving user')
Saving user: 2.750ms

更多的功能可以在Console API中找到,还有在Google官方网站的相关描述文章。

126 Responses to “ 一些你不知道的JavaScript Console调试命令 ”

  1. suba me说道:

    PkUpS2 Thank you ever so for you blog post. Really Cool.

  2. mia pron khalifa说道:

    RVdyWx Some really fantastic articles on this web site , regards for contribution.

  3. This particular blog is without a doubt awesome and also diverting. I have chosen a bunch of interesting stuff out of this amazing blog. I ad love to come back again and again. Thanks a bunch!

  4. Kickboxing说道:

    I truly appreciate this blog.Really thank you! Fantastic.

  5. It as the little changes that will make the biggest changes. Thanks for sharing!

  6. colors for kids说道:

    Sweet blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I ave been trying for a while but I never seem to get there! Appreciate it

  7. mca motor club说道:

    Looking around I like to look around the web, regularly I will just go to Digg and follow thru

  8. This particular blog is no doubt educating and besides factual. I have picked up a bunch of interesting stuff out of it. I ad love to return every once in a while. Thanks!

  9. Perfectly composed content material , thankyou for entropy.

  10. Im obliged for the article.Much thanks again. Will read on

  11. This website definitely has all of the info I needed about this subject and didn at know who to ask.

  12. website说道:

    Way cool! Some extremely valid points! I appreciate you writing this article plus the rest of the website is extremely good.

  13. This is one awesome blog.Much thanks again. Much obliged.

  14. Oluwadamilare说道:

    Thanks so much for the blog post.Really looking forward to read more. Will read on

  15. Wow! I cant believe I have found your weblog. Extremely useful info.

  16. sbobet mobile说道:

    There is visibly a lot to realize about this. I feel you made certain nice points in features also.

  17. online说道:

    There is definately a lot to learn about this issue. I love all of the points you ave made.

  18. W88说道:

    Some genuinely fantastic posts on this web site , thankyou for contribution.

  19. This article posted at this web site is in fact nice.

  20. It as really a great and helpful piece of information. I am glad that you shared this useful information with us. Please keep us up to date like this. Thank you for sharing.

  21. I think this is a real great article.Much thanks again. Will read on

  22. private Hire说道:

    I truly appreciate this blog article.Really looking forward to read more. Really Great.

  23. Im no expert, but I suppose you just crafted the best point. You undoubtedly understand what youre talking about, and I can really get behind that. Thanks for staying so upfront and so genuine.

  24. status online说道:

    There as certainly a great deal to know about this topic. I like all the points you have made.

  25. Rattling fantastic info can be found on site.

  26. I was recommended this website by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You are incredible! Thanks!

  27. H1B说道:

    Thank you for your blog article.Really looking forward to read more. Will read on

  28. Nwokolo Collins说道:

    I think this is among the most significant info

  29. you ave got a fantastic blog right here! would you wish to make some invite posts on my weblog?

  30. Wow, awesome blog format! How long have you been blogging for? you make blogging look easy. The whole look of your web site is fantastic, let alone the content material!

  31. Nwokolo说道:

    There is perceptibly a bundle to identify about this. I believe you made certain good points in features also.

  32. klm voucher说道:

    later on and see if the problem still exists.

  33. Very excellent information can be found on site.

  34. Wow, great blog post.Much thanks again. Great.

  35. hampton bay说道:

    Wow, great blog article.Really looking forward to read more. Keep writing.

  36. junk removala说道:

    I really liked your article post.Much thanks again. Really Cool.

  37. Paul McCartney说道:

    This very blog is no doubt entertaining and besides diverting. I have picked helluva helpful tips out of this source. I ad love to go back every once in a while. Thanks a bunch!

  38. The Constitution gives every American the inalienable right to make a damn fool of himself..

  39. It as really a great and useful piece of info. I am glad that you shared this helpful info with us. Please keep us up to date like this. Thank you for sharing.

  40. I reckon something really interesting about your internet blog so i bookmarked.

  41. yeezy boost 350说道:

    Thanks a lot for providing individuals with remarkably superb possiblity to discover important secrets from this website. It really is very amazing plus full of a good time for me personally and my office fellow workers to search your web site at minimum three times every week to study the newest guidance you will have. And of course, we are certainly impressed with all the superb methods you serve. Certain 4 ideas on this page are definitely the best I have had.

  42. Your style is really unique in comparison to other folks I have read stuff from. Thanks for posting when you have the opportunity, Guess I will just book mark this page.

  43. tools for sales说道:

    Wow! Thank you! I constantly wanted to write on my website something like that. Can I include a fragment of your post to my blog?

  44. soniachna dolyna说道:

    You made some really good points there. I looked on the net for more info about the issue and found most individuals will go along with your views on this website.

  45. tra hoa thao moc说道:

    Thanks for all your efforts that you have put in this. very interesting info.

  46. very good put up, i definitely love this web site, carry on it

  47. Of course, what a magnificent blog and instructive posts, I definitely will bookmark your blog.Have an awsome day!

  48. Spot on with this write-up, I actually suppose this web site needs much more consideration. I all in all probability be once more to learn rather more, thanks for that info.

  49. Muchos Gracias for your post.Thanks Again. Cool.

  50. sidekick说道:

    wonderful issues altogether, you simply received a new reader. What could you recommend in regards to your put up that you simply made a few days ago? Any certain?

  51. click here说道:

    Right now it looks like BlogEngine is the best blogging platform out there right now. (from what I ave read) Is that what you are using on your blog?

  52. share说道:

    Say, you got a nice blog post. Want more.

  53. girls说道:

    Very good publish, thanks a lot for sharing. Do you happen to have an RSS feed I can subscribe to?

  54. Really informative blog post. Want more.

  55. There is perceptibly a bunch to know about this. I think you made certain nice points in features also.

  56. Well I definitely liked reading it. This tip procured by you is very effective for accurate planning.

  57. Crochet poncho说道:

    Thanks for the blog.Really looking forward to read more. Will read on

  58. Mate! This blog is cool. How did you make it look like this !

  59. red shoes说道:

    to find something more safe. Do you have any suggestions?

  60. value说道:

    This web site definitely has all the information and facts I needed about this subject and didn at know who to ask.

  61. bot pho mai说道:

    you ave an incredible blog right here! would you like to make some invite posts on my blog?

  62. this website说道:

    I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thank you again!

  63. This rather good phrase is necessary just by the way

  64. Waec说道:

    Thanks a lot for the blog article. Fantastic.

  65. Waec expo说道:

    Very neat article.Much thanks again. Keep writing. ventolin

  66. ps4 ark servers说道:

    Thanks again for the blog post.Thanks Again. Awesome.

  67. Thanks so much for the post.Really looking forward to read more.

  68. to learn more说道:

    What kind of things can not circulate through the network.

  69. I’а†ve read several excellent stuff here. Definitely worth bookmarking for revisiting. I wonder how so much attempt you put to make any such excellent informative web site.

  70. I’а†ve learn several excellent stuff here. Certainly price bookmarking for revisiting. I surprise how so much effort you set to create this kind of wonderful informative web site.

  71. Thanks for any other great post. Where else could anybody get that kind of info in such an ideal means of writing? I ave a presentation next week, and I am at the look for such info.

  72. Really appreciate you sharing this article.Much thanks again. Keep writing.

  73. Major thankies for the blog article.Really thank you!

  74. In my opinion you commit an error. I suggest it to discuss. Write to me in PM, we will talk.

  75. What as Happening i am new to this, I stumbled upon this I have found It absolutely helpful and it has helped me out loads. I hope to contribute & help other users like its helped me. Good job.

  76. Thanks for another magnificent article. Where else could anyone get that kind of info in such an ideal way of writing? I have a presentation next week, and I am on the look for such information.

  77. pagina de ventas说道:

    Lovely site! I am loving it!! Will come back again. I am taking your feeds also

  78. Regards for this post, I am a big fan of this web site would like to go on updated.

  79. Meshack说道:

    If you are going for finest contents like I do, simply go to see this site every day since it provides quality contents, thanks

  80. resorts说道:

    This web site truly has all of the information and facts I needed concerning this subject and didn at know who to ask.

  81. Open Heaven说道:

    You could definitely see your expertise in the work you write. The world hopes for even more passionate writers like you who aren at afraid to say how they believe. Always follow your heart.

  82. Wow! This can be one particular of the most useful blogs We have ever arrive across on this subject. Basically Great. I am also a specialist in this topic so I can understand your hard work.

  83. rare to see a nice blog like this one today.

  84. Vale Flash O PORTAL MUTIMDIA DO VALE DO PARABA

  85. personal injury说道:

    This is a good tip especially to those fresh to the blogosphere. Simple but very precise info Thanks for sharing this one. A must read article!

  86. Thank you for your post.Really looking forward to read more. Great.

  87. Jualan Tas Online Murah It as great to come across a blog every once in a while that is not the same out of date rehashed material. Fantastic read!

  88. Thanks-a-mundo for the article.Really looking forward to read more. Awesome.

  89. Bump on the Gum说道:

    You have remarked very interesting details ! ps nice web site. Justice is the truth in action. by Jeseph Joubert.

  90. Some genuinely interesting details you have written.Helped me a lot, just what I was searching for .

  91. Winners说道:

    Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Kindly also visit my web site =). We could have a link exchange arrangement between us!

  92. official site说道:

    Very informative article post.Really looking forward to read more. Great.

  93. see说道:

    My brother recommended I might like this web site. He was totally right. This post actually made my day. You cann at imagine just how much time I had spent for this info! Thanks!

  94. Wonderful work! This is the type of information that should be shared around the web. Shame on Google for not positioning this post higher! Come on over and visit my website. Thanks =)

  95. visit website说道:

    I visited a lot of website but I think this one contains something special in it in it

  96. Very good blog post.Much thanks again. Really Great.

  97. more information说道:

    Wow, awesome blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is magnificent, as well as the content!. Thanks For Your article about sex.

  98. Major thanks for the blog article.Really thank you!

  99. Thank you for the post. I will definitely return.

  100. It is truly a great and useful piece of information. I am satisfied that you just shared this useful info with us. Please stay us informed like this. Thanks for sharing.

  101. Nice post. I learn something new and challenging on blogs I stumbleupon everyday. It will always be useful to read content from other authors and use something from other websites.

  102. social说道:

    To create a such kind of article is really amazing,I daily read your blogs and give my announcement for that here this article is too great and so entertaining.

  103. Nnamdi说道:

    Paragraph writing is also a excitement, if you know after that you can write or else it is complicated to write.

  104. see the website说道:

    I truly appreciate this blog.Thanks Again.

  105. This blog is obviously educating and amusing. I have picked a lot of interesting tips out of it. I ad love to visit it again soon. Thanks a bunch!

  106. Free ads说道:

    It?s arduous to search out knowledgeable folks on this subject, but you sound like you recognize what you?re talking about! Thanks

  107. go to说道:

    Nice blog here! Also your web site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my website loaded up as quickly as yours lol

  108. Lots of people will be benefited from your writing. Cheers!

  109. Wow, what a video it is! Genuinely good feature video, the lesson given in this video is truly informative.

  110. gohere说道:

    Thanks for the blog post.Much thanks again.

  111. Say, you got a nice article.Much thanks again. Much obliged.

  112. Really wonderful info can be found on web site.

  113. is rare to look a great weblog like this one these days..

  114. do vui说道:

    on other sites? I have a blog centered on the same information you discuss and would really like to

  115. copper fit说道:

    Welcome to Affordable Auto Body CARSTAR Auto Body Repair Experts Franklin, WI

  116. Really enjoyed this blog.Much thanks again. Will read on

  117. Tremendous issues here. I am very glad to see your article. Thank you so much and I am looking forward to contact you. Will you please drop me a mail?

  118. I was suggested this blog by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You are amazing! Thanks!

  119. genuine parts说道:

    It as difficult to find educated people on this topic, however, you sound like you know what you are talking about! Thanks

  120. click here说道:

    This site was how do I say it? Relevant!! Finally I ave found something which helped me. Thank you!

  121. Really enjoyed this post.Really thank you! Cool.

  122. chandana dixit说道:

    I really liked your blog post. Want more.

  123. I really liked your blog.Really looking forward to read more. Awesome.

  124. Im grateful for the article post.Really thank you! Will read on

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>