

{"id":51262,"date":"2019-03-10T11:00:39","date_gmt":"2019-03-10T05:30:39","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=51262"},"modified":"2019-08-06T18:41:34","modified_gmt":"2019-08-06T13:11:34","slug":"javascript-variable-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/","title":{"rendered":"JavaScript Variables &#8211; A to Z Guide for a Newbie in JavaScript!"},"content":{"rendered":"<p>Variable means anything that can vary and holds the data value and we can change it anytime. A variable must have a unique name. Variables in JavaScript are tanks which keeps a hold on metamorphic data. Today in this tutorial, we will learn about variables in JavaScript. We will try to understand when and how to use them. We will also take a brief look at how JavaScript variables work and the basic points you need to remember while applying them, rules associated with variables, identifiers, and keywords.<\/p>\n<p><strong><em>Before starting with this blog, we recommend you to gain a thorough understanding of <a href=\"https:\/\/data-flair.training\/blogs\/javascript-operator\/\">JavaScript Operators<\/a><\/em><\/strong><\/p>\n<p>So, let\u2019s get started with what JavaScript variables actually are.<\/p>\n<h2>What are JavaScript Variables?<\/h2>\n<p>The word <strong>\u2018variable\u2019<\/strong> means anything that can vary. Thus, the data values stored in a JavaScript variable can be changed anytime. Every programming language, be it C\/C++ or Java, uses variables. We can use variables as symbolic names for values in an application.<\/p>\n<p>Suppose you are shopping in a mall for some of your favorite items. You have a cart to put the items you want to buy in; this is your variable. You named it <strong>\u201cyourCart\u201d<\/strong>; this name you provided is an <strong>Identifier<\/strong>. You select and store everything you want in <strong>yourCart<\/strong>. Anything you put inside <strong>yourCart<\/strong> is your <strong>data<\/strong>. You can add or remove your data anytime you wish.<\/p>\n<p>This is similar to how we deal with variables in JavaScript. JavaScript variables can store any data values <em>(e.g., a number, a string, etc.).<\/em><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/Hello-message-cart.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-67141\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/Hello-message-cart.png\" alt=\"Hello message cart - JavaScript Variables\" width=\"239\" height=\"185\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/Hello-message-cart.png 239w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/Hello-message-cart-150x116.png 150w\" sizes=\"auto, (max-width: 239px) 100vw, 239px\" \/><\/a><\/p>\n<p>A variable can be created using any of the three keywords: <strong>\u2018var\u2019, \u2018let\u2019 and \u2018const\u2019.<\/strong> You don\u2019t need to worry if many of these words are new to you. You will understand these terms as you proceed further in this article.<\/p>\n<h3>Variables Scope in JavaScript<\/h3>\n<p>The region of your program where you define your variable is the variable\u2019s scope, or you can say that the lifetime of a variable is its scope. There are three types of JavaScript variables:<\/p>\n<ul>\n<li><strong>Global variables:<\/strong> They have global scope i.e. they can be defined anywhere in your JavaScript code.<\/li>\n<li><strong>Local variables:<\/strong> These are only visible in the function\u00a0in which we define them. They will not have any significance outside that function.<\/li>\n<li><strong>Block variables:<\/strong> They have block scope i.e., they are defined inside a block { }, not necessarily a function. These are added in the program with the help of<strong> \u2018let\u2019 and \u2018const\u2019<\/strong> keywords (new in EcmaScript 2015).<\/li>\n<\/ul>\n<h3>Difference between Global and Local Variables<\/h3>\n<table dir=\"ltr\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"256\" \/>\n<col width=\"207\" \/><\/colgroup>\n<tbody>\n<tr>\n<td style=\"text-align: center\"><strong>Parameter<\/strong><\/td>\n<td style=\"text-align: center\"><strong>Global<\/strong><\/td>\n<td style=\"text-align: center\"><strong>Local<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Declaration<\/td>\n<td style=\"text-align: center\">Declared outside the function.<\/td>\n<td style=\"text-align: center\">Declared inside the function.<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Scope<\/td>\n<td style=\"text-align: center\">Throughout the program.<\/td>\n<td>\n<div>\n<div style=\"text-align: center\">Within the function inside which we declared them.<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Value<\/td>\n<td style=\"text-align: center\">If not initialized, it stores zero as a default value.<\/td>\n<td>\n<div>\n<div style=\"text-align: center\">If not initialized, it stores a garbage value.<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Lifetime<\/td>\n<td style=\"text-align: center\">Created before program execution and lost when the program terminates.<\/td>\n<td>\n<div>\n<div style=\"text-align: center\">Created when the function executes and lost when the function terminates.<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Data Sharing<\/td>\n<td style=\"text-align: center\">Possible; multiple functions can access the same global variable.<\/td>\n<td>\n<div>\n<div style=\"text-align: center\">Not possible; only a single function can access the local variable.<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">Storage<\/td>\n<td style=\"text-align: center\">Stored in a fixed location decided by the compiler.<\/td>\n<td>\n<div>\n<div style=\"text-align: center\">Stored on the stack, unless specified otherwise.<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Before using global variables in your program, you must understand that it isn\u2019t always a good idea to declare a global variable. You should be very careful where you use them because of the following reasons:<\/p>\n<ul>\n<li>It is hard to know which function is using them.<\/li>\n<li>It requires larger memory space as compared to local variables.<\/li>\n<li>Multiple functions using the same variable will reduce the speed of the program.<\/li>\n<li>It sometimes becomes unreliable; debugging is difficult.<\/li>\n<li>It reduces the flexibility of your program since you will have to change many things to edit even a single thing.<\/li>\n<\/ul>\n<p><em><strong>Time to revise the <a href=\"https:\/\/data-flair.training\/blogs\/javascript-syntax\/\">JavaScript Syntax and Implementation<\/a><\/strong><\/em><\/p>\n<h3>Variable Declaration in JavaScript<\/h3>\n<p>As mentioned earlier, JavaScript uses keywords;\u00a0<strong>var, let and const<\/strong> to declare a new variable. Let\u2019s explore them all in more detail:<\/p>\n<h4>1. Using var<\/h4>\n<p>With the help of a var statement, we declare a variable, optionally initializing it to a value. We can reassign the values to the variables or redefine the variables. If you re-declare a variable, it will not lose its value. The syntax for this declaration is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var varName; \/\/without initializing\r\nvar varName = \u201cDataFlair\u201d; \/\/initialized with a string<\/pre>\n<p>Multiple variables can be declared in a single line, separating them with commas.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">var var1 = 12, var2 = \u201cDataFlair\u201d,...;<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      var var1 = \"DF\";\r\n                        document.write(\"Variable's value is \" + var1);\r\n                        document.write(\"&lt;\/br&gt;After redeclaration,&lt;\/br&gt;\");\r\n                        var var1 = \"DataFlair\";\r\n                        document.write(\"Variable's value is \" + var1);\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-65620 alignleft\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var.jpg\" alt=\"using var\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65621 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op.jpg\" alt=\"using var op\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-var-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>In JavaScript, all the declarations (including variable declarations) are processed before program execution. Thus, declaring a variable anywhere is equivalent to declaring it at the top of the code. This provides JavaScript with the functionality to use the variables before their declarations in the code. We call this behavior of variables <strong>\u201cvar hoisting\u201d.<\/strong><\/p>\n<p>But it is always recommended in programming to declare the variables before using them. This will help you avoid unintentional redeclaration of a variable.<\/p>\n<p>This variable declaration method is rarely used by programmers, and you too need to consider either let or const for your variables.<\/p>\n<h4>2. Using let<\/h4>\n<p>These are declared in a similar manner to var declared variables. But we use the let keyword instead of var; this has scope constraints. You cannot redeclare the let declared variables. You will face a SyntaxError if you try to do so. The scope of these variables is the block they are defined in, as well as any sub-blocks. The browser will throw a ReferenceError if you try to access these variables outside of their block.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">let varName1; \/\/without initializing\r\nlet varName1 = \u201cDataFlair\u201d \/\/ initialized with a string<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      {\r\n        let variable; \/\/variable declaration\r\n      document.write(variable + \"&lt;\/br&gt;\"); \/\/accessed inside the block\r\n      }\r\n      document.write(variable + \"&lt;\/br&gt;\"); \/\/cannot \r\n                        access outside the block\r\n                        let var2 = \"DF\"; \/\/variable declaration and initialization\r\n                        document.write(\"Variable's value is \" + var1);\r\n                        document.write(\"&lt;\/br&gt;After redeclaration,&lt;\/br&gt;\");\r\n                        \/\/let var2 = \"DataFlair\"; \/\/variable redeclared\r\n                       \/\/document.write(\"Variable's value is \" + var1); \/\/Uncaught SyntaxError\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-65622 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1.jpg\" alt=\"using let1\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65623 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op.jpg\" alt=\"using let1 op\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let1-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>We experimented with ReferenceError. Let\u2019s declare the initial statements as comments and remove the comments from the last two statements.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n    {\r\n        let variable; \/\/variable declaration\r\n      document.write(variable + \"&lt;\/br&gt;\"); \/\/accessed inside the block\r\n      }\r\n                        \/\/document.write(variable + \"&lt;\/br&gt;\"); \/\/cannot access outside the block\r\n                        let var2 = \"DF\"; \/\/variable declaration and initialization\r\n                        document.write(\"Variable's value is \" + var1);\r\n                        document.write(\"&lt;\/br&gt;After redeclaration,&lt;\/br&gt;\");\r\n                        let var2 = \"DataFlair\"; \/\/variable redeclared\r\n                        document.write(\"Variable's value is \" + var1); \/\/Uncaught SyntaxError\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-65624 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2.jpg\" alt=\"using let2 - JavaScript Variables\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65625 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op.jpg\" alt=\"using let2 op - JavaScript Variables\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-let2-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/h4>\n<h4>3. Using const<\/h4>\n<p>Much like variables defined using the let statement, constants are block-scoped. The const declaration creates a constant whose scope can be either global or local to the declared block in which we declare it. The value of a constant is read-only; you cannot change it through reassignment, and you can&#8217;t redeclare it. An initializer for a constant is required; i.e., you must specify its value in the same statement in which it&#8217;s declared (since you can&#8217;t alter it later). A function or a variable in the same scope cannot have the same name as the variable.<\/p>\n<p>It is a good practice to declare your constants in uppercase. This will help programmers differentiate the constants from other variables in the program.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">const VARNAME = \u201cDataFlair\u201d; \/\/ initialized with a string<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      {\r\n        const VARIABLE; \/\/SyntaxError\r\n        document.write(VARIABLE + \"&lt;\/br&gt;\"); \/\/accessed inside the block\r\n      }\r\n                        \/*const VAR3 = \"DF\"; \/\/variable declaration and initialization\r\n                        document.write(\"Variable's value is \" + VAR3);\r\n                        document.write(\"&lt;\/br&gt;After redeclaration,&lt;\/br&gt;\");\r\n                        VAR3 = \"DataFlair\"; \/\/variable redeclared\r\n                        document.write(\"Variable's value is \" + VAR3);*\/\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-65627 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1.jpg\" alt=\"using const1 -JavaScript Variables\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65629 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op.jpg\" alt=\"using const op - JavaScript Variables\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>Let\u2019s alter our code a bit. Comment the first block and remove comments from the other statements.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n  &lt;body&gt;\r\n\r\n    &lt;script&gt;\r\n      \/*{\r\n        const VARIABLE; \/\/SyntaxError\r\n        document.write(VARIABLE + \"&lt;\/br&gt;\"); \/\/accessed inside the block\r\n      }*\/\r\n      const VAR3 = \"DF\"; \/\/variable declaration and initialization\r\n      document.write(\"Variable's value is \" + VAR3);\r\n                        document.write(\"&lt;\/br&gt;After redeclaration,&lt;\/br&gt;\");\r\n                        VAR3 = \"DataFlair\"; \/\/variable redeclared\r\n                        document.write(\"Variable's value is \" + VAR3);\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-65630 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2.jpg\" alt=\"using const2\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const2-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"img-gray-border aligncenter wp-image-65631 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1.jpg\" alt=\"using const1 op - JavaScript Variables\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/using-const1-op-1-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><em><strong>Did you explore the article on <a href=\"https:\/\/data-flair.training\/blogs\/javascript-function\/\">JavaScript Functions<\/a>?<\/strong><\/em><\/p>\n<h3>Naming Variables in JavaScript<\/h3>\n<p>Variable names in JavaScript are often known as identifiers. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Identifier\">Identifiers<\/a> are a sequence of characters in a program that identifies a variable, function, or property. These are the names we use in JavaScript as a name to declare any variable.<\/p>\n<p>The rules for naming a variable includes:<\/p>\n<ul>\n<li>The first character must be a letter, a dollar sign ($) or an underscore (_).<\/li>\n<li>The rest of the variable name may contain any letter, number, dollar ($) or an underscore (_).<\/li>\n<li>Spaces and special symbols <em>(like @ ! # etc.)<\/em> are not allowed as part of variable names.<\/li>\n<li>You must not use JavaScript\u2019s reserved words as variable names.<\/li>\n<li>There is no limit for the length of the variable name.<\/li>\n<\/ul>\n<h4>Points to Remember<\/h4>\n<p><em>JavaScript doesn&#8217;t throw an error for a variable name that satisfies the above conditions. But this does not mean that you use any identifier you want.<\/em> For creating simple, easy-to-interpret, easy-to-debug and efficient programs, you <strong>must assign meaningful names to your variables<\/strong>. Some points you need to remember while naming a variable are as follows:<\/p>\n<ul>\n<li>Make sure you provide descriptive names for your variables. Using names with a few characters is easy to type. But these are only useful in small programs. When you are working on a larger project, you eventually forget the names you initially assigned.<\/li>\n<li>Since JavaScript is case-sensitive, variable and Variable are two different identifiers. But you should not use them both in your program. Your program will be more error-prone if you do so.<\/li>\n<li>Try to make your variable names as different from the keywords and other built-in terms as you can to avoid confusion.<\/li>\n<li>The best way to create a variable is to use multiple words. JavaScript programmers prefer Camel Case for their variable names <em>(e.g., myVarName)<\/em>. Except for the first character of the name, all the first words are uppercase and others are lowercase.<\/li>\n<li>You should avoid creating extremely long variable names. This will take longer to type and are more susceptible to errors.<\/li>\n<\/ul>\n<h3>JavaScript Reserved Words<\/h3>\n<p>JavaScript has some words reserved for itself. When you try to use them in your program as your variable names, JavaScript gets defensive. It\u2019s like, \u201cWoah! I\u2019m using that word, so you\u2019re not allowed to use it. You get yourself another variable name.\u201d<br \/>\nThese reserved words are famous by the name<strong> \u201ckeywords\u201d.<\/strong> Keywords are just some special words, that JavaScript uses to function. You cannot choose these words as identifiers.<\/p>\n<p>The following table lists the various EcmaScript 2015 Reserved Words in JavaScript:<\/p>\n<table dir=\"ltr\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"100\" \/><\/colgroup>\n<tbody>\n<tr>\n<td style=\"text-align: center\">break<\/td>\n<td style=\"text-align: center\">case<\/td>\n<td style=\"text-align: center\">catch<\/td>\n<td style=\"text-align: center\">class<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">const<\/td>\n<td style=\"text-align: center\">continue<\/td>\n<td style=\"text-align: center\">debugger<\/td>\n<td style=\"text-align: center\">default<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">delete<\/td>\n<td style=\"text-align: center\">do<\/td>\n<td style=\"text-align: center\">else<\/td>\n<td style=\"text-align: center\">export<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">extends<\/td>\n<td style=\"text-align: center\">finally<\/td>\n<td style=\"text-align: center\">for<\/td>\n<td style=\"text-align: center\">function<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">if<\/td>\n<td style=\"text-align: center\">import<\/td>\n<td style=\"text-align: center\">in<\/td>\n<td style=\"text-align: center\">instanceof<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">new<\/td>\n<td style=\"text-align: center\">return<\/td>\n<td style=\"text-align: center\">super<\/td>\n<td style=\"text-align: center\">switch<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">this<\/td>\n<td style=\"text-align: center\">throw<\/td>\n<td style=\"text-align: center\">try<\/td>\n<td style=\"text-align: center\">typeof<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">var<\/td>\n<td style=\"text-align: center\">void<\/td>\n<td style=\"text-align: center\">while<\/td>\n<td style=\"text-align: center\">with<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">yield<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Future Reserved Keywords<\/h3>\n<p>These keywords do not have any special functionality at present, but they might. Hence, we cannot use them as identifiers.<br \/>\nenum is always reserved.<\/p>\n<p>As listed in the following table, other keywords available in the older standards (EcmaScript 1 to 3) are:<\/p>\n<table dir=\"ltr\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"100\" \/>\n<col width=\"100\" \/><\/colgroup>\n<tbody>\n<tr>\n<td style=\"text-align: center\">abstract<\/td>\n<td style=\"text-align: center\">boolean<\/td>\n<td style=\"text-align: center\">byte<\/td>\n<td style=\"text-align: center\">char<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">double<\/td>\n<td style=\"text-align: center\">final<\/td>\n<td style=\"text-align: center\">float<\/td>\n<td style=\"text-align: center\">goto<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">int<\/td>\n<td style=\"text-align: center\">long<\/td>\n<td style=\"text-align: center\">native<\/td>\n<td style=\"text-align: center\">short<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">synchronized<\/td>\n<td style=\"text-align: center\">throws<\/td>\n<td style=\"text-align: center\">transient<\/td>\n<td style=\"text-align: center\">volatile<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You also cannot use other literals null, true and false as identifiers in EcmaScript.<\/p>\n<h2>Summary<\/h2>\n<p>Here we come to the end of our tutorial on JavaScript Variables. In this article, we went through variables and constants. We took a brief look at different types of variable, different methods to declare them, and rules for identifiers and the best practices to decide on them. And last but not least we also learned about JavaScript Keywords.<\/p>\n<p><em><strong>Thinking, what next? Here is the article on\u00a0<a href=\"https:\/\/data-flair.training\/blogs\/javascript-data-types\/\">JavaScript Data Types<\/a>\u00a0for you<\/strong><\/em><\/p>\n<p>Hope the information provided was useful to you.<\/p>\n<p>Don&#8217;t forget to drop your feedback below in the comment section.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1622,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Identifier&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251209140946\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Identifier&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-14 08:56:14&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-03 17:26:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 09:13:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-22 09:11:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 03:12:28&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-08 10:55:56&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-08 10:55:56&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Variable means anything that can vary and holds the data value and we can change it anytime. A variable must have a unique name. Variables in JavaScript are tanks which keeps a hold on&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":67142,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18979],"tags":[20565,19154,19167,19151,18982],"class_list":["post-51262","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript-keywords","tag-javascript-variable-declaration","tag-javascript-variable-naming","tag-javascript-variable-scope","tag-javascript-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Variables - A to Z Guide for a Newbie in JavaScript! - DataFlair<\/title>\n<meta name=\"description\" content=\"Explore the concept of JavaScript variables, its scope, global vs local variables, variable declaration, naming variables, and reserved words &amp; future reserved keywords in JavaScript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Variables - A to Z Guide for a Newbie in JavaScript! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Explore the concept of JavaScript variables, its scope, global vs local variables, variable declaration, naming variables, and reserved words &amp; future reserved keywords in JavaScript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-10T05:30:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-08-06T13:11:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png\" \/>\n\t<meta property=\"og:image:width\" content=\"801\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Variables - A to Z Guide for a Newbie in JavaScript! - DataFlair","description":"Explore the concept of JavaScript variables, its scope, global vs local variables, variable declaration, naming variables, and reserved words & future reserved keywords in JavaScript.","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:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Variables - A to Z Guide for a Newbie in JavaScript! - DataFlair","og_description":"Explore the concept of JavaScript variables, its scope, global vs local variables, variable declaration, naming variables, and reserved words & future reserved keywords in JavaScript.","og_url":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-03-10T05:30:39+00:00","article_modified_time":"2019-08-06T13:11:34+00:00","og_image":[{"width":801,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png","type":"image\/png"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"JavaScript Variables &#8211; A to Z Guide for a Newbie in JavaScript!","datePublished":"2019-03-10T05:30:39+00:00","dateModified":"2019-08-06T13:11:34+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/"},"wordCount":1712,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png","keywords":["JavaScript Keywords","JavaScript Variable Declaration","JavaScript Variable Naming","JavaScript Variable Scope","JavaScript Variables"],"articleSection":["JavaScript Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/","name":"JavaScript Variables - A to Z Guide for a Newbie in JavaScript! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png","datePublished":"2019-03-10T05:30:39+00:00","dateModified":"2019-08-06T13:11:34+00:00","description":"Explore the concept of JavaScript variables, its scope, global vs local variables, variable declaration, naming variables, and reserved words & future reserved keywords in JavaScript.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/08\/JavaScript-Variables.png","width":801,"height":420,"caption":"JavaScript Variables Tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/javascript-variable-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial","item":"https:\/\/data-flair.training\/blogs\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Variables &#8211; A to Z Guide for a Newbie in JavaScript!"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=51262"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51262\/revisions"}],"predecessor-version":[{"id":67146,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51262\/revisions\/67146"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/67142"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=51262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=51262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=51262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}