{"id":801,"date":"2022-07-11T08:38:59","date_gmt":"2022-07-11T08:38:59","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=801"},"modified":"2023-04-22T18:56:50","modified_gmt":"2023-04-22T18:56:50","slug":"javascript-comments","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/javascript-comments\/","title":{"rendered":"Comments in JavaScript"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>JavaScript Comments<\/strong><\/p>\n<p>Sometimes we need to write something in the code, which we wish should not execute with the code. It can be some explanation of what the particular line of code does, or if you suddenly remember while writing the code that you have to get some items from the grocery store, and you want to add those items to your code so that you don&#8217;t have to remember it (Just kidding). But if there is anything you wish should not execute with the code, but still, want to be there in the code, you can use comments.<\/p>\n<h2 style=\"text-align: center;\">Comments in JavaScript<\/h2>\n<p><iframe loading=\"lazy\" title=\"Comments in JavaScript | Lecture 8 | JavaScript for Beginners\" width=\"696\" height=\"392\" src=\"https:\/\/www.youtube.com\/embed\/B4xCiIzga1k?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>So, comments are something that is ignored by the browser. You can say that the browser considers that you wrote those lines for some personal purpose and ignore that particular line. Even if there is a commented code, it will be ignored just because it is a comment.<\/p>\n<p>The comments are also of two types &#8211;<\/p>\n<ul>\n<li>Single line comment \u2192<br \/>\nA single-line comment is one that is written in a single line.<br \/>\nOn a line, anything you write after \/\/ would be a single-line comment.<\/li>\n<li>Multiline comment \u2192<br \/>\nThe multiline comment is one that can be written in multiple lines.<\/li>\n<\/ul>\n<p>Anything written between \/\u00d7 and \u00d7\/ would be considered a comment. You will get this actually when you will see a comment.<\/p>\n<p>Here is an example that can help you understand the concepts of comments.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-802 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/04\/Comments-in-JavaScript.jpg\" alt=\"\" width=\"542\" height=\"222\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/04\/Comments-in-JavaScript.jpg 542w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/04\/Comments-in-JavaScript-300x123.jpg 300w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><\/p>\n<p>As you can see, the comments are being displayed in a different color as well. You can write comments in your programs, whenever you require them. You can use single-line comments and multiple-line comments in your program as per your requirement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript Comments Sometimes we need to write something in the code, which we wish should not execute with the code. It can be some explanation of what the particular line of code does, or if you suddenly remember while writing the code that you have to get some items from the grocery store, and you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,15],"class_list":{"0":"post-801","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-javascript-tutorial","7":"tag-javascript","8":"tag-javascript-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=801"}],"version-history":[{"count":4,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/801\/revisions"}],"predecessor-version":[{"id":6015,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/801\/revisions\/6015"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}