{"id":1,"date":"2020-07-25T18:26:18","date_gmt":"2020-07-25T18:26:18","guid":{"rendered":"http:\/\/www.datatype.co.in\/blog\/?p=1"},"modified":"2020-09-11T19:01:47","modified_gmt":"2020-09-11T19:01:47","slug":"javascript-naming-convention","status":"publish","type":"post","link":"https:\/\/datatype.co.in\/blog\/javascript-naming-convention\/","title":{"rendered":"JavaScript Naming Conventions"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"315\" src=\"https:\/\/www.datatype.co.in\/blog\/wp-content\/uploads\/2020\/09\/javascript-naming-conventions.jpg\" alt=\"JavaScript Naming Conventions\" class=\"wp-image-878\" srcset=\"https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2020\/09\/javascript-naming-conventions.jpg 851w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2020\/09\/javascript-naming-conventions-300x111.jpg 300w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2020\/09\/javascript-naming-conventions-768x284.jpg 768w, https:\/\/datatype.co.in\/blog\/wp-content\/uploads\/2020\/09\/javascript-naming-conventions-710x263.jpg 710w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<p>Every programming language has some naming convention, JavaScript is no exception. It is good practice to follow naming conventions while naming variables, functions, classes and so on. Following are some naming convention used in JS-<\/p>\n\n\n\n<p><strong>Do not use reserved keywords:<\/strong><\/p>\n\n\n\n<p>Never user reserved keywords (like return, for, boolean etc) as variable name.<\/p>\n\n\n\n<p><strong>JavaScript variable names are case sensitive:<\/strong><\/p>\n\n\n\n<p>Be careful while naming variable. JS variables are case sensitive. For example &#8211; <strong>user <\/strong>and <strong>User <\/strong>are two different variables.<\/p>\n\n\n\n<p>Do not start variable name with number:<\/p>\n\n\n\n<p>In JavaScript variable name should start with an alphabet or special characters.<\/p>\n\n\n\n<pre class=\"wp-block-code prettyprint\"><code>var 12user = 'Test' \/\/ Not valid\nvar _12user = 'Test' \/\/ This is valid\nvar _emailId= 'test@example.com' \/\/ This is valid<\/code><\/pre>\n\n\n\n<p><strong>Variables:<\/strong><\/p>\n\n\n\n<p>It is good to use small or camelCased name for variables and functions. Example :<\/p>\n\n\n\n<pre class=\"wp-block-code prettyprint\"><code>var firstName = 'Developer'; \/\/ Good\nvar firstname = \"Developer\" \/\/ Bad<\/code><\/pre>\n\n\n\n<p><strong>Functions:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code prettyprint\"><code>\/\/Good\nfunction getName(){\n   \/\/ do something\n}\n\n\/\/Bad\nfunction name(){\n   \/\/ do something\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every programming language has some naming convention, JavaScript is no exception. It is good practice to follow naming conventions while naming variables, functions, classes and so on. Following are some&nbsp;[ &hellip; ]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[84,85,87,83,86,82],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-js-naming-best-practices","tag-js-naming-conventions","tag-js-naming-functions","tag-js-naming-rules","tag-js-naming-variables","tag-naming-conventions-in-javascript","list-style-post"],"_links":{"self":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":11,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":879,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions\/879"}],"wp:attachment":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}