{"id":3655,"date":"2019-12-16T13:44:26","date_gmt":"2019-12-16T04:44:26","guid":{"rendered":"https:\/\/learningbox.co.jp\/?p=3655"},"modified":"2019-12-16T13:44:26","modified_gmt":"2019-12-16T04:44:26","slug":"blog_chrome-devtools","status":"publish","type":"post","link":"https:\/\/learningbox.co.jp\/en\/2019\/12\/16\/blog_chrome-devtools\/","title":{"rendered":"Debugging JavaScript with Chrome DevTools!"},"content":{"rendered":"<p>Hello, this is Yoshino\ud83d\udd2b from development. This time I would like to write an article about debugging JavaScript in Google Chrome browser.<\/p>\n<p class=\"mokujimidasi\">Click here for table of contents<\/p>\n<ul class=\"mokuji\">\n<li>1. what is Chrome DevTools?<\/li>\n<li>2. how to open Chrome DevTools<\/li>\n<li>3. summary<\/li>\n<\/ul>\n<h2><strong>What are Chrome DevTools?<\/strong><\/h2>\n<p>This is a debugging tool built into the Chorme browser.<br \/>\nYou can use the debug tool to debug the currently open web page.<\/p>\n<h2><strong>How to open the Chrome DevTools<\/strong><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb1.png\" alt=\"\" width=\"1097\" height=\"424\" class=\"alignnone size-full wp-image-3670\" srcset=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb1.png 1097w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb1-300x116.png 300w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb1-768x297.png 768w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb1-1024x396.png 1024w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/p>\n<p>Windows: F12 or Shift + Ctrl + I<br \/>\nMac: Cmd + Opt + I<br \/>\nThis is the only way to use the sophisticated debugging tools.<\/p>\n<h3><strong>I'll put a breakpoint on it.<\/strong><\/h3>\n<p>Chrome DevTools has many debugging features, but this time I'd like to show you how to debug JavaScript using breakpoints.<\/p>\n<p>When you click the part of the line number of the source code displayed in the main area, the blue arrow is displayed and the breakpoint is set. The breakpoint can be placed on the code, and when the processing of the place where it is placed runs, it pauses, and the value of the variable of the timing that stopped can be confirmed in detail.<\/p>\n<div class=\"box28\">\n    <span class=\"box-title\">How to place a breakpoint<\/span><\/p>\n<p>1. Open DevTools<br \/>\n2. Click the Sources tab at the top of DevTools.<br \/>\n3. Click on the JavaScript code where you want to place the breakpoint<br \/>\n4. Click the line number column on the left when the code is displayed.<br \/>\n5.It is OK if the clicked part turns blue.<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb2.png\" alt=\"\" width=\"1315\" height=\"742\" class=\"alignnone size-full wp-image-3673\" srcset=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb2.png 1315w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb2-300x169.png 300w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb2-768x433.png 768w, https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb2-1024x578.png 1024w\" sizes=\"auto, (max-width: 1315px) 100vw, 1315px\" \/><\/p>\n<h2><strong>step over<\/strong><\/h2>\n<p>Step over and step out are useful to see the general flow of the process. Stepover executes all the internal processing of the function and stops at the next line, if the function is running on the line where it is currently stopped.<\/p>\n<p>Let's say we have a function where we enter numbers in x and y and pass the calculation method in type. Let's put a breakpoint at \"result = -1\".<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/00.gif\" alt=\"\" width=\"515\" height=\"323\" class=\"alignnone size-full wp-image-3664\" \/><br \/>\nYou can check the flow of the process and the value in the variable while proceeding with the code like this. This is stepping over the process by pressing the F10 key.<\/p>\n<p>Step over means that when the function reaches a line, it doesn't go into the function, but pretends that it has executed the process in the function and proceeds to process the next line.<\/p>\n<h3><strong>step in<\/strong><\/h3>\n<p>However, you can't follow the contents of the add function in step over.<br \/>\nIf you want to follow the process inside the called function, you can use step-in.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/01.gif\" alt=\"\" width=\"515\" height=\"323\" class=\"alignnone size-full wp-image-3665\" \/><\/p>\n<p>Now we can follow the process inside the add function.<br \/>\nThe step-in process is done by pressing the F11 key.<\/p>\n<h3><strong>restarting a process<\/strong><\/h3>\n<p>Next, let's place multiple breakpoints.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/02.gif\" alt=\"\" width=\"515\" height=\"323\" class=\"alignnone size-full wp-image-3666\" \/><br \/>\nBy pressing the F8 key to restart the process, we were able to advance the process to the next breakpoint.<\/p>\n<h3><strong>operation procedures<\/strong><\/h3>\n<p>F8 : Resume processing<br \/>\nF10: Step over<br \/>\nF11: Step in<\/p>\n<h2><strong>summary<\/strong><\/h2>\n<p>In this article, I explained the basic debugging method when a breakpoint is placed.<br \/>\nIn the next article, I would like to introduce setting conditional breakpoints and so on.<\/p>","protected":false},"excerpt":{"rendered":"\u3053\u3093\u306b\u3061\u306f\u3001\u958b\u767a\u306e\u5409\u91ce\ud83d\udd2b\u3067\u3059\u3002\u4eca\u56de\u306fGoogle Chrome\u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u306eJavaScript\u306e\u30c7\u30d0\u30c3\u30b0\u306b\u3064 [&hellip;]","protected":false},"author":22,"featured_media":3669,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"0","footnotes":""},"categories":[6,7,40],"tags":[],"class_list":["post-3655","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-7","category-40"],"acf":[],"jetpack_featured_media_url":"https:\/\/learningbox.co.jp\/wp-content\/uploads\/2019\/12\/Chrome\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb.png","jetpack_shortlink":"https:\/\/wp.me\/pgMrZ4-WX","_links":{"self":[{"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/posts\/3655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/comments?post=3655"}],"version-history":[{"count":17,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/posts\/3655\/revisions"}],"predecessor-version":[{"id":3658,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/posts\/3655\/revisions\/3658"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/media\/3669"}],"wp:attachment":[{"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/media?parent=3655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/categories?post=3655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learningbox.co.jp\/en\/wp-json\/wp\/v2\/tags?post=3655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}