{"id":6275,"date":"2020-09-25T22:47:38","date_gmt":"2020-09-25T13:47:38","guid":{"rendered":"https:\/\/nebikatsu.com\/en\/?p=6275"},"modified":"2020-09-25T23:32:15","modified_gmt":"2020-09-25T14:32:15","slug":"what-is-console-in-javascript-it-makes-confuse-js-beginners","status":"publish","type":"post","link":"https:\/\/nebikatsu.com\/en\/6275\/","title":{"rendered":"What is console in Javascript? It makes confuse JS beginners."},"content":{"rendered":"<p><img class=\"alignnone wp-image-6285 size-full\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h17_46.jpg\" alt=\"What the hell is Console in Javascript?\" width=\"864\" height=\"514\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h17_46.jpg 864w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h17_46-300x178.jpg 300w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h17_46-768x457.jpg 768w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/p>\n<div class=\"st-kaiwa-box kaiwaicon3 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">I started to learn Javascript. But I don&#8217;t get it what to do with what I learnt when I make websites or apps. I&#8217;m about to give up.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2019\/10\/2019-10-16_10h23_31.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\"><\/div><\/div><\/div>\n<p>Don&#8217;t you feel Javascript is just too difficult? <br \/>\nDo you feel you don&#8217;t know what you are doing when you learn Javascript?<\/p>\n<p>And while you are learning Javascript, you must feel <strong>&#8220;What the hell is Console? Where is it? Is Console a browser window or not?&#8221;<\/strong><\/p>\n<p>I felt the same way when I started learning.<\/p>\n<p>So I&#8217;ll teach you what the hell is Console in Javascript and you won&#8217;t confuse any more!<\/p>\n<p>&nbsp;<\/p>\n<h2>What is Console in Javascript? What is it for?<\/h2>\n<p>Why a lot of Javascript rookies give up learning? Because they don&#8217;t get the word &#8220;Console&#8221;. Then I&#8217;ll explain very simply.<\/p>\n<p>For example, if you make a website just using HTML, Then Just what you input will come out on the browser.<\/p>\n<p>But when you learn Javascript, many books and learning sites let you output texts on Console. If you could output the collect text on Console, teachers say &#8220;Well done!&#8221;. But you don&#8217;t know what you are doing and how to use console when you build a website or app.<\/p>\n<p>Then check the image below.<\/p>\n<p><a href=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h45_52.jpg\"><span class=\"photoline\"><img class=\"alignnone size-full wp-image-6276\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h45_52.jpg\" alt=\"\" width=\"358\" height=\"388\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h45_52.jpg 358w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_20h45_52-277x300.jpg 277w\" sizes=\"(max-width: 358px) 100vw, 358px\" \/><\/span><\/a><\/p>\n<p>When you right click anywhere on a website, &#8220;Inspect&#8221; function will appear.<\/p>\n<p>Then choose Inspect.<\/p>\n<p><span class=\"photoline\"><img class=\"alignnone size-full wp-image-6149\" src=\"https:\/\/nebikatsu.com\/wp-content\/uploads\/2020\/09\/2020-09-25_14h23_16.jpg\" alt=\"\" width=\"740\" height=\"325\" \/><\/span><\/p>\n<p>The window comes out the bottom of your browser. And there is Console tab. Yes. This is Console.<\/p>\n<p>Console shows if your Javascript is broken or have errors.<\/p>\n<p>Also if you use <span class=\"st-code\">console.log()<\/span>tag on your javascript code, then what you input will come out here too.<\/p>\n<div class=\"st-kaiwa-box kaiwaicon3 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">OK, So I understand this window is Console. However, even if I could show &#8220;Hello world&#8221; or some garbage words on Console, so what? I still can&#8217;t build a website by myself with Javascript. This is bullshit, isn&#8217;t it?<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2019\/10\/2019-10-16_10h23_31.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\"><\/div><\/div><\/div>\n<div class=\"st-kaiwa-box kaiwaicon1 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">Right. Javascript beginners don&#8217;t really get it what Console is used for. That&#8217;s why, many beginners feel Javascript is too difficult and will give up. But actually Console is used for checking there are errors or not. And fix them. This is called &#8220;Debug&#8221;.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/03\/2020-03-10_23h16_39.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\">Neby<\/div><\/div><\/div>\n<p>&nbsp;<\/p>\n<h3>Console is to check what is wrong with your Javascript code.<\/h3>\n<p>OK, so I&#8217;ll show you an example of how to use console.<\/p>\n<p>If you know this, you will make sense how to learn Javascript more and you are no longer rookie.<\/p>\n<p>For example, you want to add &#8220;voice pronounce buttons&#8221; on your website.\u00a0<\/p>\n<p><span class=\"photoline\"><img class=\"alignnone size-full wp-image-6277\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h22_51.jpg\" alt=\"\" width=\"123\" height=\"45\" \/><\/span><\/p>\n<p><a href=\"https:\/\/nebikatsu.com\/en\/lesson1en.html\" target=\"_blank\" rel=\"noopener noreferrer\">Demo page<\/a><\/p>\n<p>If you click one of buttons, it pronounce the word.<br \/>\nYou must often see these on dictionary websites.<\/p>\n<p>Then to build this Javascript function, I wrote the code like below.<\/p>\n<p><img class=\"alignnone size-full wp-image-6278\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h22_24.jpg\" alt=\"\" width=\"500\" height=\"385\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h22_24.jpg 500w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h22_24-300x231.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/p>\n<p><span style=\"color: #ff0000;\">But, the button &#8220;cool&#8221; doesn&#8217;t work. But &#8220;cold&#8221; works.<\/span><\/p>\n<p>Then you need to look for where is the wrong part like &#8220;<span class=\"st\">Where&#8217;s Wally?&#8221;. But if the code is huge, you might take a couple of days to fix the code.<\/span><\/p>\n<p>It&#8217;s not smart way to do. That&#8217;s why you need to use <span class=\"st-code\">console.log()<\/span> tag!<\/p>\n<p><img class=\"alignnone size-full wp-image-6280\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h34_25.jpg\" alt=\"\" width=\"486\" height=\"232\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h34_25.jpg 486w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h34_25-300x143.jpg 300w\" sizes=\"(max-width: 486px) 100vw, 486px\" \/><\/p>\n<p>Like above. Add <span class=\"st-code\">console.log(text);<\/span>. Then you can check whether the word &#8220;cool&#8221; is passed from HTML to Javascript or not.<\/p>\n<p>Open Console (right click wherever the website and choose &#8220;Inspect&#8221;) and click &#8220;Cold&#8221; button,<\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"photoline\"><img class=\"alignnone wp-image-6281 size-full\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h38_49-e1601037772307.jpg\" alt=\"\" width=\"182\" height=\"56\" \/><\/span><\/p>\n<p>Then &#8220;cold&#8221; comes out on Console. It means, <span class=\"st-code\">function play(text)<\/span> received the word properly from HTML Button.<\/p>\n<p><span style=\"color: #993300;\">&lt;button class=&#8221;speak-btn&#8221; onclick=&#8221;<span class=\"huto\">play(&#8216;cold&#8217;)<\/span>&#8220;&gt;Cold&lt;\/button&gt;<\/span><\/p>\n<p>So now you know the code<span class=\"st-code\"> play(&#8216;cold&#8217;)<\/span> is working properly.<\/p>\n<p>Then click &#8220;Cool&#8221; button next.<\/p>\n<p><span class=\"photoline\"><img class=\"alignnone size-full wp-image-6282\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h42_27.jpg\" alt=\"\" width=\"413\" height=\"85\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h42_27.jpg 413w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_21h42_27-300x62.jpg 300w\" sizes=\"(max-width: 413px) 100vw, 413px\" \/><\/span><\/p>\n<p>This time, &#8220;cool&#8221; doesn&#8217;t come out, but &#8220;Uncaught ReferenceError&#8221; is came out.<br \/>\nIt means, <span class=\"st-code\">function play(text)<\/span> didn&#8217;t receive the word from HTML property.<\/p>\n<p>It means&#8230;<\/p>\n<p><span class=\"photoline\"><img class=\"alignnone wp-image-6283 size-full\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/console2en-e1601038224846.jpg\" alt=\"\" width=\"500\" height=\"232\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/console2en-e1601038224846.jpg 500w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/console2en-e1601038224846-300x139.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/span><\/p>\n<p>There is wrong part above console.log(text);.<\/p>\n<p>The mistake is <span class=\"st-code\">play(cool)<\/span> needs to be <span class=\"st-code\">(&#8216;cool&#8217;)<\/span>.<\/p>\n<p>OK, so do you get it?<\/p>\n<p>If Console showed &#8216;cool&#8217; properly, but still the button didn&#8217;t work. Then below console.log() had something wrong. Then you would add <span class=\"st-code\">console.log(uttr);<\/span> next. And check whether next line is working or broken.<\/p>\n<p><img class=\"alignnone size-full wp-image-6294\" src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_22h41_56.jpg\" alt=\"\" width=\"434\" height=\"138\" srcset=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_22h41_56.jpg 434w, https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/09\/2020-09-25_22h41_56-300x95.jpg 300w\" sizes=\"(max-width: 434px) 100vw, 434px\" \/><\/p>\n<p>Use Console and testing whether working properly or not, this is called &#8220;debug&#8221;.<\/p>\n<p>&nbsp;<\/p>\n<div class=\"st-kaiwa-box kaiwaicon3 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">I see. Now I understand what console.log is for.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2019\/10\/2019-10-16_10h23_31.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\"><\/div><\/div><\/div>\n<div class=\"st-kaiwa-box kaiwaicon1 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">Great. &#8220;console.log&#8221; tag is for debug. So actually you don&#8217;t need to use it to make Javascript work. But many books and learning sites use console.log tag to check your code is working properly or not.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/03\/2020-03-10_23h16_39.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\">Neby<\/div><\/div><\/div>\n<div class=\"st-kaiwa-box kaiwaicon3 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">OK. But why just don&#8217;t they just show how to use Javascript on HTML to teach Javascript? It&#8217;s more easier to understand. Don&#8217;t you think so?<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2019\/10\/2019-10-16_10h23_31.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\"><\/div><\/div><\/div>\n<div class=\"st-kaiwa-box kaiwaicon1 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">You are very right. However, when teach Javascript basic code, and using HTML, they have to explain a lot of things and learner more confuse. Also they have to prepare more to teaching. That&#8217;s why use Console and &#8220;console.log()&#8221; and make it simple.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2020\/03\/2020-03-10_23h16_39.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\">Neby<\/div><\/div><\/div>\n<div class=\"st-kaiwa-box kaiwaicon3 clearfix\"><div class=\"st-kaiwa-area2\"><div class=\"st-kaiwa-hukidashi2\">OK. It made a sense.<\/div><\/div><div class=\"st-kaiwa-face2\"><img src=\"https:\/\/nebikatsu.com\/en\/wp-content\/uploads\/2019\/10\/2019-10-16_10h23_31.jpg\" width=\"60px\"><div class=\"st-kaiwa-face-name2\"><\/div><\/div><\/div>\n<p>&nbsp;<\/p>\n<div class=\"st-blackboard\">\n<p class=\"st-blackboard-title-box\"><span class=\"st-blackboard-title\">Summary<\/span><\/p>\n<ul class=\"st-blackboard-list st-no-ck-off\">\n<li>Console appears right click the webpage and select &#8220;Inspect&#8221;.<\/li>\n<li>console.log is used for finding errors (debugging).<\/li>\n<\/ul>\n<\/div>\n<p>If you understand these. Then now you understand what you are doing properly in Javascript. Enjoy learning!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I started to learn Javascript. But I don&#8217;t get it what to do with what I learnt when I make websites or apps. I&#8217;m about to give up. Don&#8217;t you feel Javascript is just too difficult? Do you feel you don&#8217;t know what you are doing when you learn Javascript? And while you are learning Javascript, you must feel &#8220;What the hell is Console? Where is it? Is Console a browser window or not?&#8221; I felt the same way when I started learning. So I&#8217;ll teach you what the hell is Console in Javascript and you won&#8217;t confuse any more! &#8230; <\/p>\n","protected":false},"author":1,"featured_media":6285,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[156],"tags":[159],"_links":{"self":[{"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/posts\/6275"}],"collection":[{"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/comments?post=6275"}],"version-history":[{"count":16,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/posts\/6275\/revisions"}],"predecessor-version":[{"id":6301,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/posts\/6275\/revisions\/6301"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/media\/6285"}],"wp:attachment":[{"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/media?parent=6275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/categories?post=6275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nebikatsu.com\/en\/wp-json\/wp\/v2\/tags?post=6275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}