{"id":827,"date":"2021-04-20T04:20:07","date_gmt":"2021-04-20T04:20:07","guid":{"rendered":"https:\/\/usemynotes.com\/?p=827"},"modified":"2023-05-23T03:58:00","modified_gmt":"2023-05-23T03:58:00","slug":"what-is-javascript","status":"publish","type":"post","link":"https:\/\/usemynotes.com\/what-is-javascript\/","title":{"rendered":"What is JavaScript and Why Learn JavaScript?"},"content":{"rendered":"<p>Welcome back guys, in this module, we are going to talk about <strong>What is JavaScript<\/strong>, the things which make JavaScript, a powerful and popular programming language. By knowing JavaScript, you may start loving this programming language and want to start a career in the same. So, let\u2019s begin and know what exactly is JS.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#What_is_JavaScript\" >What is JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#History_of_JavaScript\" >History of JavaScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#Why_learn_JavaScript\" >Why learn JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#How_does_JavaScript_work\" >How does JavaScript work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#Uses_of_JavaScript\" >Uses of JavaScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#Requirements\" >Requirements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#How_to_write_JavaScript\" >How to write JavaScript?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#1_Internal_JavaScript\" >1. Internal JavaScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#2_External_JavaScript\" >2. External JavaScript<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#How_to_print_%E2%80%9CHello_World%E2%80%9D_in_JavaScript\" >How to print \u201cHello, World!\u201d in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#How_to_write_Comments_in_JavaScript\" >How to write Comments in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#Types_of_comments_in_Javascript\" >Types of comments in Javascript<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#1_Single-line_comment\" >1. Single-line comment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/usemynotes.com\/what-is-javascript\/#2_Multi-line_comment\" >2. Multi-line comment<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"What_is_JavaScript\"><\/span>What is JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>JavaScript or JS is a High-Level &amp; Interpreted Language because it uses an interpreter. JavaScript code is executed on the client&#8217;s web browser such as google chrome, firefox, safari, etc. so, it is also known as a client-side scripting language.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-848 size-full\" src=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript.jpg\" alt=\"What is JavaScript\" width=\"997\" height=\"557\" title=\"\" srcset=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript.jpg 997w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript-300x168.jpg 300w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript-768x429.jpg 768w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript-150x84.jpg 150w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript-696x389.jpg 696w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/what-is-javascript-752x420.jpg 752w\" sizes=\"(max-width: 997px) 100vw, 997px\" \/><br \/>\nEvery web browser has a <a href=\"https:\/\/usemynotes.com\/javascript\/\">JavaScript<\/a> engine that executes the JavaScript code. For example, Chrome has a V8 engine and Mozilla Firefox has Spider Monkey.<\/p>\n<p>It is also an untyped or dynamically typed language which means that you don\u2019t need to declare variables along with their data types like other programming languages like C, C++, and Java which are statically typed.<\/p>\n<p>In JS, you just need to write keywords either var, let, or const along with the variable name. <strong>For example &#8211;<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar a;\r\nlet b;\r\nconst c = 10;\r\n<\/pre>\n<p>Here, var, let, and const are the keywords in JavaScript used to declare variables which we will learn later in the next article.<\/p>\n<p>Like other programming languages, JavaScript is also a Case-Sensitive Language which means uppercase &amp; lowercase are not the same.<\/p>\n<p>It is a programming language for the web and also supports OOPs concepts i.e. classes, objects, etc. Let\u2019s know some history of JavaScript.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"History_of_JavaScript\"><\/span>History of JavaScript<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>JavaScript was developed by Brendan Eich in May 1995. Earlier, it was known by the name Mocha but later in 1997, it became ECMA Standard. Now, ECMAScript is the official name of JavaScript and is also maintained by them. Every year they keep on adding new features.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_learn_JavaScript\"><\/span>Why learn JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You might be thinking about why to learn JavaScript while there are also some other popular programming languages.<\/p>\n<ul>\n<li>JavaScript is used as a front-end language on the Web.<\/li>\n<li>As a web developer, it is required to have an understanding of JavaScript along with HTML and CSS to make interactive web pages.<\/li>\n<li>HTML just provides structure to your web page, CSS is used to add styling to web pages, for example, adding background colour, font style, size, etc. But to add functionalities to your web page like changing HTML content or background colour on a button click then you need to use JavaScript.<\/li>\n<li>Nowadays, JS has become a powerful programming language that is also used as a Backend Language with the help of NodeJS which is built on Chrome\u2019s V8 Engine.<\/li>\n<li>JavaScript has many libraries and frameworks used to build Web and Mobile applications.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_does_JavaScript_work\"><\/span>How does JavaScript work?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As I have mentioned earlier that every web browser has JavaScript Engine to execute JavaScript Code.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-835 aligncenter\" src=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work.png\" alt=\"how does javascript work\" width=\"845\" height=\"403\" title=\"\" srcset=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work.png 845w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work-300x143.png 300w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work-768x366.png 768w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work-150x72.png 150w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/04\/how-does-javascript-work-696x332.png 696w\" sizes=\"(max-width: 845px) 100vw, 845px\" \/><\/p>\n<p>A parser is used to parse the code line-by-line (because JS is an interpreted language) and checks for syntax and errors, if there exists some error then it stops parsing &amp; throws an error otherwise it produces a data structure known as Abstract Syntax Tree (AST).<\/p>\n<p>Abstract Syntax Tree translates JS code to Machine Code and finally, the code is executed on the client&#8217;s browser.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Uses_of_JavaScript\"><\/span>Uses of JavaScript<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li>Used in form validation like checking empty input field, password length, etc.<\/li>\n<li>Used in the field of Web development, Mobile Development and Desktop App Development.<\/li>\n<li>Nowadays, it is used as a server-side scripting language with the help of NodeJS.<\/li>\n<li>They are used to add functionalities to web pages.<\/li>\n<li>It is also used in Game Development.<\/li>\n<li>Used to change the appearance or presentation of a web page.<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"Requirements\"><\/span>Requirements<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Basics of HTML and CSS.<\/li>\n<li>Any Code editor such as Notepad, Notepad++, VS Code, Sublime Text, etc.<\/li>\n<li>A Web Browser.<\/li>\n<li>If you know any other programming language then it is good for you but if not then you don\u2019t need to worry. But the basics of HTML &amp; CSS are necessary to learn JavaScript.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"How_to_write_JavaScript\"><\/span>How to write JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We can write JavaScript in 2 ways:<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Internal_JavaScript\"><\/span>1. Internal JavaScript<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>JavaScript Developers write JavaScript code inside an HTML file and add JS code inside the script tag.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n     &lt;script&gt;\r\n        document.write('Hello');\r\n     &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_External_JavaScript\"><\/span>2. External JavaScript<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>We write JavaScript code in another file and save the file with the .js extension.<br \/>\nWe include this file inside the HTML file using the script tag.<\/p>\n<p>Create two files with the names \u201c<strong>index.js<\/strong>\u201d and \u201c<strong>index.html<\/strong>\u201d and fill those files with the following content.<\/p>\n<p><strong>index.js<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ndocument.write('&lt;h1&gt;Hello&lt;\/h1&gt;');\r\n<\/pre>\n<p><strong>index.html<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n    &lt;script type=&quot;text\/javascript&quot; src='index.js'&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"How_to_print_%E2%80%9CHello_World%E2%80%9D_in_JavaScript\"><\/span>How to print \u201cHello, World!\u201d in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>1. Using document.write()<\/strong><br \/>\nDisplaying message in HTML document.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;script type='text\/javascript'&gt;\r\n    document.write('Hello,World!');\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>2. Using console.log()<\/strong><br \/>\nPrints message in the browser console.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n     &lt;script type='text\/javascript'&gt;\r\n     console.log('Hello,World!');\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"How_to_write_Comments_in_JavaScript\"><\/span>How to write Comments in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Comments in the program are used to make it readable and understandable.<br \/>\nIt is used to explain or describe a program and is never executed by an interpreter.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Types_of_comments_in_Javascript\"><\/span>Types of comments in Javascript<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_Single-line_comment\"><\/span>1. Single-line comment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Starts and ends with \/\/.<\/p>\n<p><strong>For example,<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ Printing message\r\ndocument.write(&quot;Hello World!&quot;);\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_Multi-line_comment\"><\/span>2. Multi-line comment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Starts with \/* and ends with *\/.<\/p>\n<p><strong>For example,<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/* This is a multi-line comment.\r\nPrinting message *\/\r\ndocument.write(&quot;Hello World!&quot;);\r\n<\/pre>\n<p>I hope this module has helped you a lot in knowing about <strong>what is JavaScript<\/strong> and you might be excited to begin your career in this. For getting more modules like this, stay connected with us. Until then, Stay Happy, Stay safe and keep coding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back guys, in this module, we are going to talk about What is JavaScript, the things which make JavaScript, a powerful and popular programming language. By knowing JavaScript, you may start loving this programming language and want to start a career in the same. So, let\u2019s begin and know what exactly is JS. What [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":848,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":{"0":"post-827","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"_links":{"self":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":0,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/media\/848"}],"wp:attachment":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}