{"id":192,"date":"2015-04-08T18:57:03","date_gmt":"2015-04-08T18:57:03","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=192"},"modified":"2015-04-09T17:55:31","modified_gmt":"2015-04-09T17:55:31","slug":"chrome-developer-tips-and-tricks","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=192","title":{"rendered":"Chrome Developer Tips and Tricks"},"content":{"rendered":"<p>We&#8217;ve all spent time solving problems that have been addressed in new releases of languages or tools. I just found the following and am surprised by the toolset available for troubleshooting in Chrome. If you find yourself troubleshooting Javascript, take a look at <a href=\"https:\/\/developer.chrome.com\/devtools\/docs\/tips-and-tricks\">Tips and Tricks for Chrome Devtools<\/a> before solving a problem that no longer exists. The following examples are taken from the Google Devtools page.<\/p>\n<p>Grouping Console Log Items<\/p>\n<p>Console will nest a series of responses that are preceded by console.group() and terminated by console.groupEnd();<\/p>\n<p>Example:<\/p>\n<pre><code>console.group(\"Authentication phase\");\nconsole.log(\"Authenticating user '%s'\", user);\n\/\/ authentication code here...\nif (!authenticated) {\n    console.log(\"User '%s' not authenticated.\", user)\n}\nconsole.groupEnd();\n<\/code><\/pre>\n<p>Table Formatting for Objects and Arrays<\/p>\n<p>Console can output objects and arrays as a table with the headers the property names or array index.<\/p>\n<pre><code>console.table([{a:1, b:2, c:3}, {a:\"foo\", b:false, c:undefined}]);\n<\/code><\/pre>\n<p>Dir displays non-enumerable and hierarchical information. Exceptionally helpful for checking html elements.<\/p>\n<pre><code>console.dir(document.body.getElementsByTagName('a');\n<\/code><\/pre>\n<p>Track the Time it takes for a process to complete<\/p>\n<pre><code>console.time(\"Array initialize\");\n    var array= new Array(1000000);\n    for (var i = array.length - 1; i &gt;= 0; i--) {\n        array[i] = new Object();\n    };\nconsole.timeEnd(\"Array initialize\");\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve all spent time solving problems that have been addressed in new releases of languages or tools. I just found the following and am surprised by the toolset available for troubleshooting in Chrome. If you find yourself troubleshooting Javascript, take a look at Tips and Tricks for Chrome Devtools before solving a problem that no [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192"}],"version-history":[{"count":4,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}