{"id":26750,"date":"2016-07-06T23:01:23","date_gmt":"2016-07-06T15:01:23","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=26750"},"modified":"2017-10-31T19:48:52","modified_gmt":"2017-10-31T11:48:52","slug":"useful-javascript-statements","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/","title":{"rendered":"4 Useful JavaScript Statements You Should Know"},"content":{"rendered":"<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\" target=\"_blank\">JavaScript statements<\/a> give us the power to <strong>implement different types of logic in our code.<\/strong> JavaScript provides us with <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\" target=\"_blank\">several of them<\/a>, all of which has its own purpose and syntax. Among the most well-known examples we can find expression statements, iteration statements, conditional statements, and more<\/p>\n<p>In today\u2019s post we\u2019ll see <strong>four less common JavaScript statements<\/strong> you may not have known before, but can deepen your JavaScript knowledge, and enable you to write better code.<\/p>\n<h2>1. Empty Statement<\/h2>\n<p>In place of any JavaScript statement, you can add an <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/Empty\" target=\"_blank\">empty statement<\/a>, which is written as a single semi-colon <code><strong>;<\/strong><\/code>. When the JavaScript interpreter interprets an empty statement, <strong>no code is executed<\/strong>, therefore they can be useful to <strong>replace sub-statements that you don\u2019t want to execute<\/strong>.<\/p>\n<p>For instance, assume there\u2019s a variable called <code>litmus<\/code> with the default value <code>neutral<\/code>. Based on the value of another variable called <code>pH<\/code>, <code>litmus<\/code> changes to either <code>acidic<\/code> when pH &lt; 7 or <code>basic<\/code> when pH &gt; 7.<\/p>\n<p>If the value of <code>pH<\/code> turns out to be invalid, an error is thrown. For a <em>condition<\/em> like this, the following conditional statements apply:<\/p>\n<pre>\r\nvar litmus = 'neutral';\r\nvar pH; \r\n\r\nif(pH&gt;0 && pH&lt;7) \r\n    litmus = 'acidic';\r\nelse if(pH&gt;7 && pH&lt;15)\r\n    litmus = 'basic';\r\nelse\r\n    throw \"Invalid pH value\";\r\n<\/pre>\n<p>However the above set of statements throws an error when <code>pH<\/code>\u2018s value is 7, which shouldn\u2019t be the case.<\/p>\n<p>When <code>pH<\/code> is 7, <code>litmus<\/code> should keep its default value, that is <code>neutral<\/code>. So, for a case like this, add a condition when <code>pH<\/code> is 7 with a trailing empty statement.<\/p>\n<pre>\r\nvar litmus = 'neutral';\r\nvar pH; \r\n\r\nif(pH&gt;0 && pH&lt;7)\r\n    litmus = 'acidic';\r\nelse if(pH===7)\r\n    ;       \/* empty statement *\/\r\nelse if(pH&gt;7 && pH&lt;15)\r\n    litmus = 'basic';\r\nelse\r\n    throw \"Invalid pH value\";<\/pre>\n<p>Now, when <code>pH<\/code> is 7, the interpreter doesn\u2019t execute any instructions, and <code>litmus<\/code> keeps its default value, <code>neutral<\/code>.<\/p>\n<p>Empty statements can also be used to populate an array with the help of the <code>for<\/code> loop.<\/p>\n<pre>\r\nvar ary = [];\r\n\r\nfor(var i = 0; i &lt; 5; ary[i++] = i)\r\n;       \/* empty statement *\/\r\nconsole.log(ary); \r\n\/\/ [1, 2, 3, 4, 5]<\/pre>\n<p>Typically, a <code>for<\/code> loop statement is followed by a sub-statement that is made up of a single, or a block statement (the one enclosed in <code>{}<\/code> curly brackets) to be executed. By using an empty statement in place of the sub-statement, the interpreter won\u2019t have anything to execute after each loop, so <strong>only the <em>looping<\/em> occurs, and the looping conditions get executed<\/strong>.<\/p>\n<p>In the above example, <code>ary[i++] = i<\/code> executes for each loop iteration as part of the looping condition, and the array <code>ary<\/code> gets instantiated with values of <code>i<\/code>.<\/p>\n<h2>2. The <code>debugger<\/code> Statement<\/h2>\n<p>In debugging tools, we can <strong>add markers<\/strong> called <em>breakpoints<\/em> to any line in the source code to <strong>mark the lines from where the debugger tool will start debugging<\/strong>.<\/p>\n<p>In JavaScript, the <code><a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/JavaScript\/Reference\/Statements\/debugger\" target=\"_blank\">debugger<\/a><\/code> statement <strong>works the same way as a breakpoint<\/strong>, except that it\u2019s <strong>added into the source code directly<\/strong>, rather than within a tool. Any running debugger will <strong>halt the script execution<\/strong> when it reaches the <code>debugger<\/code> statement in order to help you debug the code.<\/p>\n<p>Remember, the debugging will get triggered <strong>only if the script is running in a debugging mode<\/strong>, i.e. a debugging program is already running over the execution of the script. If there is no currently running debugger program while interpreting the <code>debugger<\/code> statement, the interpreter will continue its work as if nothing happened.<\/p>\n<p>As a quick test, run the following code in Codepen, while keeping the browser\u2019s debugger tool open:<\/p>\n<pre>\r\nconsole.log('tesing');\r\ndebugger;\r\nconsole.log('debugging statement');<\/pre>\n<p>You\u2019ll see a breakpoint besides the <code>debugger<\/code> statement as shown below in the browser\u2019s debugger tool.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg\" alt=\"debugger output\" width=\"871\" height=\"224\"><\/figure>\n<h2>3. Labeled Statement<\/h2>\n<p>In JavaScript, you can add <a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/JavaScript\/Reference\/Statements\/label\" target=\"_blank\">labels<\/a> to certain statements as well. By doing so, you can <strong>later jump to the labeled statement<\/strong> using its label in your code, <em>kind of<\/em> like the <code>goto<\/code> statement works in some other languages.<\/p>\n<p>Labeled statements can only be used together with the <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/break\" target=\"_blank\">break<\/a><\/code> and <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/continue\" target=\"_blank\">continue<\/a><\/code> statements, as in JavaScript there\u2019s no literal <code>goto<\/code> statement.<\/p>\n<p>Both <code>break<\/code> and <code>continue<\/code> can only be used inside looping statements, such as the <code>for<\/code> loop (with one exception, <code>break<\/code> can be used in the <code>switch<\/code> statement as well). So, we can label loops, and use <code>break<\/code> and <code>continue<\/code> to control their execution.<\/p>\n<p>The <strong>syntax of labeled statements<\/strong> is simple, you just need to add the name of the label with a following colon, as you can see it in the example below, where <code>loop<\/code> is the name of the label we add to the <code>for<\/code> loop.<\/p>\n<pre>\r\nloop: for(var i=0; i&lt;5; i++){\r\n    if(i===2) \r\n        continue loop;\r\n    console.log(i); \r\n    \/\/ 0, 1, 3, 4\r\n}<\/pre>\n<p>When the value of <code>i<\/code> is 2, the execution jumps back to the loop instead of proceeding and hence prevents the console output of \u201c2\u201d.<\/p>\n<p>Now let\u2019s see another example with the <code>break<\/code> statement. Just replace the <code>continue<\/code> keyword with <code>break<\/code> in the above example, and you will notice that instead of jumping back to the loop like it did with <code>continue<\/code>, the loop ends\/breaks altogether.<\/p>\n<pre>\r\nloop: for(var i=0; i&lt;5; i++){\r\n    if(i===2) \r\n        break loop;\r\n    console.log(i); \r\n    \/\/ 0, 1\r\n}<\/pre>\n<p>The examples above were rather simple so that you can quickly understand how labeled statements work, but in real-life coding,  labels are more frequently used in compound loops, when it\u2019s necessary to distinguish the different loops, like in the following example:<\/p>\n<pre>\r\nloop: for(var i=0; i&lt;4; i++) {\r\nfor(var j=0; j&lt;2; j++) {   \r\n    if(i===2 && j===1) \r\n        break loop;\r\n    console.log(i+\"-\"+j);     \r\n}<\/pre>\n<p>Here, the <strong>outer loop <em>breaks<\/em><\/strong> at value 2 for variable <code>i<\/code> and at 1 for <code>j<\/code>, and the console returns the following output:<\/p>\n<pre>\r\n0-0\r\n0-1\r\n1-0\r\n1-1\r\n2-0<\/pre>\n<h2>4. The <code>with<\/code> Statement<\/h2>\n<p>When the JS interpreter <strong>comes across an unqualified name<\/strong> that doesn\u2019t specify which object or function the call is associated with, it <strong>searches the scope chain<\/strong> for any suitable object or function the call may refer to.<\/p>\n<p>By using the <code><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/with\" target=\"_blank\">with<\/a><\/code> statement, we can <strong>add an object to the top the scope chain<\/strong>, and specify which object the call is associated with.<\/p>\n<p>In the following example, you can see that the properties of the <code>person<\/code> object are called using their names alone inside the <code>with<\/code> statement.<\/p>\n<pre>\r\nvar person = {\r\n    firstName: \"John\",\r\n    lastName: \"Doe\",\r\n    age: \"18\",\r\n    country: \"Greenland\"\r\n};\r\n\r\nwith(person) {\r\n    console.log(\"Hi, my name is \" + firstName + \" \" + lastName + \r\n    \". I'm \" + age + \" years old, and live in \" + country + \".\");\r\n}\r\n\/\/ \"Hi, my name is John Doe. I'm 18 years old, and live in Greenland.\"<\/pre>\n<p>Compare how the code above would look like without using the <code>with<\/code> statement:<\/p>\n<pre>\r\nvar person = {\r\n    firstName: \"John\",\r\n    lastName: \"Doe\",\r\n    age: \"18\",\r\n    country: \"Greenland\"\r\n};\r\n\r\nconsole.log(\"Hi, my name is \" + person.firstName + \" \" + \r\nperson.lastName + \". I'm \" + person.age + \r\n\" years old, and live in \" + person.country + \".\");\r\n\/\/ \"Hi, my name is John Doe. I'm 18 years old, and live in Greenland.\"<\/pre>\n<p>You can see, the <code>with<\/code> statement can be a great shortcut if you work with many properties of the same object.<\/p>\n<p>Note however, that using the <code>with<\/code> statement <strong>in strict mode is not allowed<\/strong>, since it can cause some scope confusion.<\/p>\n<p>Also, it\u2019s only advised to use the <code>with<\/code> statement if its internal statements use the object associated with the <code>with<\/code> statement, otherwise the interpreter will waste time looking into the object mentioned by <code>with<\/code> first, for all the unqualified property names it later finds inside the <code>with<\/code> block.<\/p>","protected":false},"excerpt":{"rendered":"<p>JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has its own purpose and syntax. Among the most well-known examples we can find expression statements, iteration statements, conditional statements, and more In today\u2019s post we\u2019ll see four less common&hellip;<\/p>\n","protected":false},"author":145,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[4117],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>4 Useful JavaScript Statements You Should Know - Hongkiat<\/title>\n<meta name=\"description\" content=\"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"4 Useful JavaScript Statements You Should Know\" \/>\n<meta property=\"og:description\" content=\"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-06T15:01:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-31T11:48:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg\" \/>\n<meta name=\"author\" content=\"Preethi Ranjit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Preethi Ranjit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"4 Useful JavaScript Statements You Should Know\",\"datePublished\":\"2016-07-06T15:01:23+00:00\",\"dateModified\":\"2017-10-31T11:48:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/\"},\"wordCount\":949,\"commentCount\":13,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/useful-javascript-statements\\\/four-js-statement-debugger-output.jpg\",\"keywords\":[\"Javascripts\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/\",\"name\":\"4 Useful JavaScript Statements You Should Know - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/useful-javascript-statements\\\/four-js-statement-debugger-output.jpg\",\"datePublished\":\"2016-07-06T15:01:23+00:00\",\"dateModified\":\"2017-10-31T11:48:52+00:00\",\"description\":\"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/useful-javascript-statements\\\/four-js-statement-debugger-output.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/useful-javascript-statements\\\/four-js-statement-debugger-output.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/useful-javascript-statements\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"4 Useful JavaScript Statements You Should Know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\",\"name\":\"Preethi Ranjit\",\"description\":\"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/preethi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"4 Useful JavaScript Statements You Should Know - Hongkiat","description":"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/","og_locale":"en_US","og_type":"article","og_title":"4 Useful JavaScript Statements You Should Know","og_description":"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has","og_url":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2016-07-06T15:01:23+00:00","article_modified_time":"2017-10-31T11:48:52+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg","type":"","width":"","height":""}],"author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"4 Useful JavaScript Statements You Should Know","datePublished":"2016-07-06T15:01:23+00:00","dateModified":"2017-10-31T11:48:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/"},"wordCount":949,"commentCount":13,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg","keywords":["Javascripts"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/","url":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/","name":"4 Useful JavaScript Statements You Should Know - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg","datePublished":"2016-07-06T15:01:23+00:00","dateModified":"2017-10-31T11:48:52+00:00","description":"JavaScript statements give us the power to implement different types of logic in our code. JavaScript provides us with several of them, all of which has","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/useful-javascript-statements\/four-js-statement-debugger-output.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/useful-javascript-statements\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"4 Useful JavaScript Statements You Should Know"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3","name":"Preethi Ranjit","description":"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.","url":"https:\/\/www.hongkiat.com\/blog\/author\/preethi\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-6Xs","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/145"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=26750"}],"version-history":[{"count":1,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26750\/revisions"}],"predecessor-version":[{"id":26751,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/26750\/revisions\/26751"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=26750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=26750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=26750"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=26750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}