{"id":5540,"date":"2021-03-13T12:55:46","date_gmt":"2021-03-13T12:55:46","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5540"},"modified":"2021-03-13T12:55:46","modified_gmt":"2021-03-13T12:55:46","slug":"javascript-basics","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/","title":{"rendered":"Javascript Basics"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">JavaScript is the world&#8217;s most popular programming language. Some of the advantages of javascript are given below:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Client side execution<\/li><li>Validation on browser<\/li><li>Easy language<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Disadvantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It is comparatively less secure.<\/li><li>No hardware access<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ways of adding javascript:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inline &#8211; We can javascript inside the head tag or the body tag between &lt;script>&#8230;&lt;\/script>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">External &#8211; We can create a javascript file externally and link it inside the head tag or the body tag between &lt;script>&#8230;&lt;\/script>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To link a java file to html file:-<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;script src=&#8221;abc.js&#8221; type=&#8221;text\/script&#8221;> &lt;\/script><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Some of the functions of javascript is given below:-<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Write function<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">*document.write()<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It displays the content into page.<\/li><li>If we use this function in the end of the HTML document it will delete all existing HTML.<\/li><li>It is used only for testing purpose.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:- document.write(variable); , document.write(4+2);<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Alert function<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">*window.alert()<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It displays the data in the alert box.<\/li><li>It should be used when you want the user to stop and see the alert.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:- window.alert(&#8220;hello world&#8221;); , window.alert(&#8220;4+2);<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Identifiers<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is a name having few letters, numbers and special characters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is used to identify var, function, symbolic constant and so on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:- X2 , PI , Sigma<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Variable<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is an identifier or a name which is used to refer a value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is written with a combination of letters, numbers and special character with first letter being alphabet (Underscore &amp; Dollar) also.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ex:- C , fact , b33 , total_amount<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Data type<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In javascript we do not have to specify type of variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;Var&#8221; can hold any type of data like string , number ,  boolean etc<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Primitive data types:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Data Type<\/th><th>Description<\/th><\/tr><tr><td>String<\/td><td>represents sequence of characters e.g. &#8220;hello&#8221;<\/td><\/tr><tr><td>Number<\/td><td>represents numeric values e.g. 100<\/td><\/tr><tr><td>Boolean<\/td><td>represents boolean value either false or true<\/td><\/tr><tr><td>Undefined<\/td><td>represents undefined value<\/td><\/tr><tr><td>Null<\/td><td>represents null i.e. no value at all<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Non-Primitive data types:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Data Type<\/th><th>Description<\/th><\/tr><tr><td>Object<\/td><td>represents instance through which we can access members<\/td><\/tr><tr><td>Array<\/td><td>represents group of similar values<\/td><\/tr><tr><td>RegExp<\/td><td>represents regular expression<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Declaring Variable<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">var roll;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">roll= name;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here &#8216;roll&#8217; is the variable name and &#8216;name&#8217; is assigning value to variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If a variable is declared without a value then its value will be undefined.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Important points in Javascript:-<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Statements are executed one by one as they are written.<\/li><li>Javascripts program and statements are often called Javascripts code.<\/li><li>Semicolons separates javascript statements.<\/li><li>Ending statement with semicolon is not required but it is highly recommended.<\/li><li>Javascript ignores multiple spaces.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript is the world&#8217;s most popular programming language. Some of the advantages of javascript are given below: Client side execution [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5540","post","type-post","status-publish","format-standard","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Javascript Basics - scmGalaxy<\/title>\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.scmgalaxy.com\/tutorials\/javascript-basics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Basics - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"JavaScript is the world&#8217;s most popular programming language. Some of the advantages of javascript are given below: Client side execution [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-13T12:55:46+00:00\" \/>\n<meta name=\"author\" content=\"Joydeep M\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joydeep M\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/\"},\"author\":{\"name\":\"Joydeep M\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\"},\"headline\":\"Javascript Basics\",\"datePublished\":\"2021-03-13T12:55:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/\"},\"wordCount\":430,\"commentCount\":0,\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/\",\"name\":\"Javascript Basics - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-03-13T12:55:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/javascript-basics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Javascript Basics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\",\"name\":\"Joydeep M\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"caption\":\"Joydeep M\"},\"description\":\"An investment in knowledge pays the best interest.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/joydeep-kumar-538412208\\\/\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/joydeep\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript Basics - scmGalaxy","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.scmgalaxy.com\/tutorials\/javascript-basics\/","og_locale":"en_US","og_type":"article","og_title":"Javascript Basics - scmGalaxy","og_description":"JavaScript is the world&#8217;s most popular programming language. Some of the advantages of javascript are given below: Client side execution [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/","og_site_name":"scmGalaxy","article_published_time":"2021-03-13T12:55:46+00:00","author":"Joydeep M","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joydeep M","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/"},"author":{"name":"Joydeep M","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6"},"headline":"Javascript Basics","datePublished":"2021-03-13T12:55:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/"},"wordCount":430,"commentCount":0,"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/","name":"Javascript Basics - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-03-13T12:55:46+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/javascript-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Javascript Basics"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6","name":"Joydeep M","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","caption":"Joydeep M"},"description":"An investment in knowledge pays the best interest.","sameAs":["https:\/\/www.linkedin.com\/in\/joydeep-kumar-538412208\/"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/joydeep\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5540"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5540\/revisions"}],"predecessor-version":[{"id":5545,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5540\/revisions\/5545"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}