{"id":12443,"date":"2020-05-08T17:04:45","date_gmt":"2020-05-09T00:04:45","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12443"},"modified":"2023-12-01T02:45:00","modified_gmt":"2023-12-01T10:45:00","slug":"javascript-let","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/javascript-let\/","title":{"rendered":"A Step-By-Step Guide to JavaScript Let"},"content":{"rendered":"\n<p><em>Let in JavaScript is one of three ways to declare a variable. JavaScript let is used to declare block scope variables and cannot be reassigned or redeclared. The let variable is best used for loops. <\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Variables are an essential part of most programming languages. When you\u2019re getting started in JavaScript, you\u2019ll encounter the term a lot. \u201cVariable\u201d is used to describe a container that stores a value or values in your code.<br><\/p>\n\n\n\n<p>There are three ways to declare a variable in JavaScript: var, let, and const. Each of these variable types can be used in different circumstances, which we discuss later in this article.<br><\/p>\n\n\n\n<p>That said, the focus of this tutorial is the JavaScript keyword \u201clet.\u201d \u201cLet\u201d allows you to declare variables that can be reassigned. We\u2019ll discuss how the \u201clet\u201d keyword works in JavaScript and explore an example of declaring variables using \u201clet.\u201d<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Variable Refresher<\/h2>\n\n\n\n<p>JavaScript variables store values. For example, if we have a name that we want to store in our code, we may want to assign it to a variable. Variables can hold any data type, including numbers, strings, and objects.<br><\/p>\n\n\n\n<p>The most common way to declare a variable in JavaScript is to use \u201cvar,\u201d in large part because the original language specification on which JavaScript is based did not include multiple ways to declare a variable. Here\u2019s the syntax for declaring a variable using \u201cvar:\u201d<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var full_name = \"John Appleseed\";<\/pre><\/div>\n\n\n\n<p>In the example above, we declared a variable called \u201cname\u201d and assigned it the value \u201cJohn Appleseed\u201d. Our variable has a few components:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The variable is declared using the \u201cvar\u201d keyword.<\/li>\n\n\n\n<li>The name of our variable is \u201cfull_name.\u201d<\/li>\n\n\n\n<li>The \u201c=\u201d syntax tells our program to assign our variable \u201cfull_name\u201d with a value.<\/li>\n\n\n\n<li>The value assigned to our variable is \u201cJohn Appleseed.\u201d<\/li>\n<\/ul>\n\n\n\n<p>Now that we have our variable declared, we can use it throughout our code. In the following code, we print out our variable name:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>console.log(full_name);<\/pre><\/div>\n\n\n\n<p>Our program returns: \u201cJohn Appleseed\u201d.&nbsp;<br><\/p>\n\n\n\n<p>In this example, our variable is a string, but we could have assigned it a number, an array, a JSON object, a boolean, or any other type of data. Here\u2019s an example of a variable that stores an array:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var attendees = ['John', 'Ruby', 'Caleb', 'Emily'];<\/pre><\/div>\n\n\n\n<p>In this example, we have declared a variable called \u201cattendees.\u201d This variable stores four strings, which are the names of people who may be attending our example concert.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Variable Types<\/h2>\n\n\n\n<p>The examples above use the \u201cvar\u201d keyword to declare a variable, but sometimes using another keyword is more appropriate. That\u2019s where the \u201clet\u201d and \u201cconst\u201d keywords come in.&nbsp;<br><\/p>\n\n\n\n<p>In JavaScript, we can declare variables using each of these three keywords, which are used in different circumstances.<br><\/p>\n\n\n\n<p>The table below shows the differences between these three types of variables:<br><\/p>\n\n\n\n<figure class=\"wp-block-table course-info-table\"><table><tbody><tr><td>Keyword<\/td><td>Variable Scope<\/td><td>Reassign?<\/td><td>Redeclare?<\/td><td>Hoist?<\/td><\/tr><tr><td>var<\/td><td>Function<\/td><td>Yes<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><tr><td>const<\/td><td>Block<\/td><td>Yes<\/td><td>No<\/td><td>No<\/td><\/tr><tr><td>let<\/td><td>Block<\/td><td>No<\/td><td>No<\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This table looks complex, but when you start using the different types of variables, you\u2019ll begin to develop a better understanding of when each one should be used.&nbsp;<br><\/p>\n\n\n\n<p>The following are general rules of thumb for using these types of variables:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Use <strong>const<\/strong> as much as possible, <strong>unless you need to redeclare or hoist a variable<\/strong>.&nbsp;<\/li>\n\n\n\n<li>Use <strong>let<\/strong> if you are working with <strong>loops<\/strong>.&nbsp;<\/li>\n\n\n\n<li>Only use <strong>var<\/strong> if:\n<ol class=\"wp-block-list\">\n<li>You are working on <strong>legacy code<\/strong>,&nbsp;<\/li>\n\n\n\n<li>You need a variable that you can redeclare, or<\/li>\n\n\n\n<li>You need a variable accessible <strong>everywhere in the program (i.e., globally)<\/strong>.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<p>Two mnemonics to help you remember the three keywords for variables in JavaScript and when to use each are:<br><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><em>Variables<\/em><\/strong><em> are <\/em><strong><em>con<\/em><\/strong><em>tainers that <\/em><strong><em>let<\/em><\/strong><em> you store <\/em><strong><em>va<\/em><\/strong><em>lue in your code.<\/em><\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Const<\/strong>antine could not redeclare nor hoist the<\/li>\n<\/ol>\n\n\n\n<p><strong>Let<\/strong>tuce through loops, so the<\/p>\n\n\n\n<p><strong>Var<\/strong>iety of veggies became a global legacy.<br><\/p>\n\n\n\n<p>Let\u2019s now look at the \u201clet\u201d keyword. We will explore its use in JavaScript and how it compares to the other keywords for variables.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Let<\/h2>\n\n\n\n<p>The JavaScript \u201clet\u201d keyword allows you to declare a block scope variable. (Unlike global variables, block scope variables are local to the block in which they are declared.) Recall that you declare global variables with \u201cvar.\u201d<br><\/p>\n\n\n\n<p>What does this mean? <em>Scope<\/em> refers to where you can access a variable in your code. \u201cblock scope\u201d refers to the area within a loop or conditional statement. Generally, curly brackets ({}) distinguish a block of code.<br><\/p>\n\n\n\n<p>Local variables are variables declared inside a block of code. Global variables, on the other hand, are declared outside.<\/p>\n\n\n\n<p>The &#8220;let&#8221; keyword is useful in programs that use variables in an &#8220;if&#8221; statement or a &#8220;for&#8221; loop.<\/p>\n\n\n\n<p>Here\u2019s an example of the JavaScript \u201clet\u201d keyword in action:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var workday = true;\nlet lunchFruit = \"Apple\";\nif (workday) {\n\tlet lunchFruit = \"Banana\";\n\tconsole.log(`It is a workday. Pack a ${lunchFruit} for lunch today.`);\n}\nconsole.log(`It is not a workday. Pack a ${lunchFruit} for lunch today.`);<\/pre><\/div>\n\n\n\n<p>Our code returns the following:<br><\/p>\n\n\n\n<p>It is a workday. Pack a Banana for lunch today.<\/p>\n\n\n\n<p>It is not a workday. Pack a Apple for lunch today.<br><\/p>\n\n\n\n<p>In this example, we declare two variables: \u201cworkday\u201d and \u201clunchFruit.\u201d \u201cworkday\u201d is a global scope variable that we can access throughout our program (notice that the code uses \u201cvar\u201d), and \u201clunchFruit\u201d is a local variable that can be accessed reassigned only within our loop (notice that the code uses \u201clet\u201d).<br><\/p>\n\n\n\n<p>When our program executes the \u201cif\u201d statement, it sees that \u201cworkday\u201d is equal to \u201ctrue.\u201d Thus, our program runs the code in the \u201cif\u201d block. In this case, our program reassigns \u201clunchFruit\u201d to \u201cBanana,\u201d and then prints a message to the console.<br><\/p>\n\n\n\n<p>But when our program finishes running the code in the \u201cif\u201d statement, it prints out the message \u201cIt is not a workday. Pack a Apple today.\u201d This is because our \u201clunchFruit\u201d variable only changes within our \u201cif\u201d statement. The name of the fruit does not change because our final console.log() lies outside of the \u201cif\u201d statement.<br><\/p>\n\n\n\n<p>The code above demonstrates the two key attributes of the \u201clet\u201d variable:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u201clet\u201d has block scope, which means it can only be accessed in a certain block.<\/li>\n\n\n\n<li>\u201clet\u201d can be reassigned if we want it to, but only within our block scope.<\/li>\n<\/ol>\n\n\n\n<p>If we wanted our variable to be global, we would use \u201cvar\u201d instead, but because the example above uses an \u201cif\u201d statement, we only needed to use the \u201clet\u201d variable.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Let Alternatives<\/h2>\n\n\n\n<p>To illustrate the differences between \u201cvar\u201d and \u201clet\u201d in more depth, here\u2019s an example of the same code above, but using \u201cvar\u201d instead of \u201clet\u201d to declare our \u201clunchFruit\u201d variable:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var workday = true;\nvar lunchFruit = \"Apple\";\nif (workday) {\n\tvar lunchFruit = \"Banana\";\n\tconsole.log(`It is a workday. Pack a ${lunchFruit} for lunch today.`);\n}\nconsole.log(`It is not a workday. Pack a ${lunchFruit} for lunch today.`);\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>It is a workday. Pack a Banana for lunch today.<\/p>\n\n\n\n<p>It is not a workday. Pack a Banana for lunch today.<br><\/p>\n\n\n\n<p>As you can see, when our code changes the \u201clunchFruit\u201d variable\u2019s value to \u201cBanana,\u201d the change is made globally, so when our code runs the final \u201cconsole.log()\u201d statement, it prints the \u201clunchFruit\u201d variable which stores the value \u201cBanana.\u201d<br><\/p>\n\n\n\n<p>Additionally, we can use \u201cconst\u201d to declare a variable. However, unlike variables declared using the \u201clet\u201d keyword, once we have declared the variable, we cannot redeclare it.<br><\/p>\n\n\n\n<p>Here\u2019s an example of declaring a variable using the \u201cconst\u201d keyword:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const full_name = \"John Appleseed\";<\/pre><\/div>\n\n\n\n<p>The variable \u201cfull_name\u201d now stores \u201cJohn Appleseed.\u201d But if we wanted to change the name, we would have to declare a new variable, like so:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const first_full_name = \"John Appleseed.\"\nconst second_full_name = \"John Doe.\"<\/pre><\/div>\n\n\n\n<p>If we tried to reassign the variable \u201cfull_name,\u201d our program would return an error, \u201cfull_name has already been declared.\u201d So, \u201cconst\u201d can be useful for storing values that will not change, but if you anticipate that you\u2019ll need to redeclare a variable, you may want to use \u201cvar.\u201d<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Variables are a crucial part of programming. In this tutorial, we discussed the basics of variables and how to work with \u201cvar\u201d and \u201clet\u201d in JavaScript. We also briefly discussed the differences between \u201cvar,\u201d \u201clet,\u201d and \u201cconst,\u201d and how each of these variable keywords should be used in JavaScript.<br><\/p>\n\n\n\n<p>Now you\u2019re ready to declare JavaScript variables like a professional developer!<\/p>\n","protected":false},"excerpt":{"rendered":"Let in JavaScript is one of three ways to declare a variable. JavaScript let is used to declare block scope variables and cannot be reassigned or redeclared. The let variable is best used for loops. Variables are an essential part of most programming languages. When you\u2019re getting started in JavaScript, you\u2019ll encounter the term a&hellip;","protected":false},"author":240,"featured_media":12445,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-12443","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>A Step-By-Step Guide to JavaScript Let | Career Karma<\/title>\n<meta name=\"description\" content=\"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/javascript-let\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Step-By-Step Guide to JavaScript Let\" \/>\n<meta property=\"og:description\" content=\"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/javascript-let\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-09T00:04:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:45:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"A Step-By-Step Guide to JavaScript Let\",\"datePublished\":\"2020-05-09T00:04:45+00:00\",\"dateModified\":\"2023-12-01T10:45:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/\"},\"wordCount\":1306,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/eyeglasses-in-front-of-laptop-computer-1181253.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/\",\"name\":\"A Step-By-Step Guide to JavaScript Let | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/eyeglasses-in-front-of-laptop-computer-1181253.jpg\",\"datePublished\":\"2020-05-09T00:04:45+00:00\",\"dateModified\":\"2023-12-01T10:45:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/eyeglasses-in-front-of-laptop-computer-1181253.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/02\\\/eyeglasses-in-front-of-laptop-computer-1181253.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript-let\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"A Step-By-Step Guide to JavaScript Let\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/jamesgallagher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"A Step-By-Step Guide to JavaScript Let | Career Karma","description":"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.","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:\/\/careerkarma.com\/blog\/javascript-let\/","og_locale":"en_US","og_type":"article","og_title":"A Step-By-Step Guide to JavaScript Let","og_description":"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.","og_url":"https:\/\/careerkarma.com\/blog\/javascript-let\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-05-09T00:04:45+00:00","article_modified_time":"2023-12-01T10:45:00+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"A Step-By-Step Guide to JavaScript Let","datePublished":"2020-05-09T00:04:45+00:00","dateModified":"2023-12-01T10:45:00+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/"},"wordCount":1306,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/javascript-let\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/","url":"https:\/\/careerkarma.com\/blog\/javascript-let\/","name":"A Step-By-Step Guide to JavaScript Let | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg","datePublished":"2020-05-09T00:04:45+00:00","dateModified":"2023-12-01T10:45:00+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Coders use the \u201clet\u201d keyword to declare certain variables in JavaScript. Learn about the JavaScript \u201clet\u201d keyword and more in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/javascript-let\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/eyeglasses-in-front-of-laptop-computer-1181253.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/javascript-let\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"A Step-By-Step Guide to JavaScript Let"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=12443"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12443\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12445"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}