{"id":16762,"date":"2016-07-13T00:27:37","date_gmt":"2016-07-13T00:27:37","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=16762"},"modified":"2016-07-13T00:28:08","modified_gmt":"2016-07-13T00:28:08","slug":"javascript-output-to-the-console","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/javascript-output-to-the-console\/","title":{"rendered":"JavaScript:  output to the console"},"content":{"rendered":"<h1>The tutor tests JavaScript code using the console.<\/h1>\n<p>I&#8217;ve long known about the JavaScript console, and use it sometimes for debugging.  However, I didn&#8217;t know to use if for testing &#8211; until now.<\/p>\n<p>In the past, I&#8217;d build a rudimentary web page around a JavaScript function, sending the output to a div using innerHTML.  However, for checking continuity and logic, sending output to the console might be simpler.  Testing it today, I&#8217;d just open Notepad, type<\/p>\n<p>&lt;script&gt;<\/p>\n<p>lines<br \/>\nof<br \/>\ncode<br \/>\nto be<br \/>\ntested<\/p>\n<p><span style=\"font-family:monospace;font-weight:500\">console.log(<\/span>Output you want to see<span style=\"font-family:monospace;font-weight:500\">);<\/span><\/p>\n<p>&lt;\/script&gt;<\/p>\n<p>then save the file as html and point the browser to it.  Of course, at first, I&#8217;d just get a blank screen.  F12 opens the developer tools, then clicking Console shows the output.   <\/p>\n<p>In the JavaScript code, the command<\/p>\n<p><span style=\"font-family:monospace;font-weight:500\">console.log(<\/span>Output you want to see<span style=\"font-family:monospace;font-weight:500\">);<\/span><\/p>\n<p>sends the output to the console.  If for some reason there&#8217;s a problem, you know right away:  that&#8217;s what the console is there to tell you.  Therefore, it&#8217;s a great testing utility.<\/p>\n<p>HTH:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/www.w3schools.com\/js\/js_output.asp\">w3schools<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor tests JavaScript code using the console. I&#8217;ve long known about the JavaScript console, and use it sometimes for debugging. However, I didn&#8217;t know to use if for testing &#8211; until now. In the past, I&#8217;d build a rudimentary &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/javascript-output-to-the-console\/\"> <span class=\"screen-reader-text\">JavaScript:  output to the console<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,1662],"tags":[842,205,1711,1712],"class_list":["post-16762","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-web-browsers","tag-f12","tag-javascript","tag-javascript-output-to-console","tag-testing-javascript"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=16762"}],"version-history":[{"count":56,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16762\/revisions"}],"predecessor-version":[{"id":16855,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/16762\/revisions\/16855"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=16762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=16762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=16762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}