{"id":23825,"date":"2020-10-07T11:22:53","date_gmt":"2020-10-07T18:22:53","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23825"},"modified":"2022-07-20T08:44:04","modified_gmt":"2022-07-20T15:44:04","slug":"let-vs-var","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/let-vs-var\/","title":{"rendered":"Let vs Var vs Const: What\u2019s the Difference?"},"content":{"rendered":"\n<p>New features have been added to the JavaScript language with the release of ECMAScript6 (ES6). One such feature affects how we declare variables. With the addition of <code>let<\/code> and <code>const<\/code>, came all sorts of questions about when to use each of the variable declarations.\u00a0<br><\/p>\n\n\n\n<p>In this post, we talk about each of the options, with respect to their definition and use in the JavaScript environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pre-ES6: Var<\/h2>\n\n\n\n<p>Prior to the release of ES6, the keyword used to declare variables was <code>var<\/code>.\u00a0<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var hello = &quot;Hello, World&quot;;\nconsole.log(hello);<\/pre><\/div>\n\n\n\n<p>Vars can also be redeclared and updated with no errors.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var hello = &quot;Hello, World&quot;;\nconsole.log(hello); \/\/Hello, World\n \nvar hello = &quot;Hello, Mars&quot;;\nconsole.log(hello); \/\/Hello, Mars<\/pre><\/div>\n\n\n\n<p>The first problem with var is evident: redeclarations can cause bugs in your code if a variable has already been assigned to the same name. There can be unintended consequences if something is redeclared and you didn\u2019t realize that variable name had already been used earlier in the codebase. Along with this, too, comes some other idiosyncrasies when it comes to <a href=\"https:\/\/careerkarma.com\/blog\/javascript-closure\/\">scope<\/a>, and hoisting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scope<\/h3>\n\n\n\n<p>Scope tells us what variables are available for us to use \u2013 we have variables that can be globally or locally scoped. What happens if we have the same variable declaration, but one is global and the other is local?<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var hello = &quot;Hello, World&quot;;\nconsole.log(hello); \/\/Hello, World\n \nfunction helloWorld(){\n   var hello = &quot;Hello, Again!&quot;;\n   console.log(hello); \/\/Hello, Again!\n   return hello;\n}\n \nhelloWorld()\n \nconsole.log(hello); \/\/Hello, World<\/pre><\/div>\n\n\n\n<p>When we have our var declared outside the function, it\u2019s globally available to us global-scoped. When \u201chello\u201d<em> <\/em>is declared inside the function, it is only available to the function \u2013 function- or local-scoped.<br><\/p>\n\n\n\n<p>When we have a variable declaration that is the same, but the scope is different, the var inside the function does nothing to change the assignment of the global var, even with the invocation of the <code>helloWorld()<\/code> function. Because the var is declared inside the function with the name \u201chello\u201d, it doesn\u2019t look to the global scope for the other definition.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hoisting<\/h3>\n\n\n\n<p>When a variable is hoisted in JavaScript, the declaration of functions and variables are moved to the top of their scope prior to code execution. The variable is declared but not initialized, so the initial value of the variable is undefined.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>console.log(hello); \/\/undefined\nvar hello = &quot;Hello, World&quot;;<\/pre><\/div>\n\n\n\n<p>Here, \u201chello\u201d is hoisted and declared at the top of your scope. So essentially, the computer is interpreting the code as this:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>var hello;\nconsole.log(hello);\/\/undefined\nvar hello = &quot;Hello, World!&quot;<\/pre><\/div>\n\n\n\n<p>The JavaScript engine sees that hello exists but it doesn\u2019t know what hello is defined as until the next pass through.<br><\/p>\n\n\n\n<p>Ultimately, the developers that helped to create the ECMAScript Standard realized that there were some little problems with var that could cost time and money. They then set out to create stricter keywords. This led to the creation of \u201clet\u201d and \u201cconst\u201d in ES6.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ES6: Let<\/h2>\n\n\n\n<p>The <code>let<\/code><em> <\/em>keyword is very similar to the var keyword in many ways. The main differences lay within how errors are returned and how each keyword is scoped.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let hello = &quot;Hello, World&quot;;\nconsole.log(hello);<\/pre><\/div>\n\n\n\n<p>Variables declared and initialized with the <code>let<\/code> keyword can be reassigned, but they can not be redeclared.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let hello = &quot;Hello, World&quot;;\nhello = &quot;Hello, Mars!&quot;; \/\/this does not throw an error\nconsole.log(hello);\nlet hello = &quot;Hello, Again!&quot;; \/\/this will throw an error<\/pre><\/div>\n\n\n\n<p>When you run the code above in a JavaScript console, the last line will throw an error:\u00a0<\/p>\n\n\n\n<p><code>SyntaxError: Identifier 'hello' has already been declared<\/code><\/p>\n\n\n\n<p>Unlike <code>var<\/code>, declaring variables using <code>let<\/code> will not allow for a declaration to the same variable name again. You can, however, reassign it if you wish, as shown in the example above.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scope<\/h3>\n\n\n\n<p>In regards to scope, <code>let<\/code> is very similar to <code>var<\/code>. In addition to the rules, being globally- or locally-scoped gives us, there is an added constraint with <code>let<\/code>. Variables declared inside a block of code are only available to that block of code. This is similar to functional scope because functions are blocks of code that can be carried even further by having separate blocks inside that function.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let hello = &quot;Hello, World&quot;;\n \nfunction helloWorld(){\n   if(hello) {\n       let hello = &quot;Hello Inside Block&quot;\n       console.log(hello, &quot;inside block&quot;); \/\/Hello Inside Block inside block\n   }\n   console.log(hello, &quot;outside block&quot;)\/\/Hello, World outside block\n}\n \nhelloWorld()<\/pre><\/div>\n\n\n\n<p>There is no error in this code since both instances of hello are treated as separate variables since they have different scopes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hoisting<\/h3>\n\n\n\n<p>Hoisting is another area where let and var declarations are similar. \u201cvar\u201d, when hoisted to the top, is initialized as undefined. However, \u201clet\u201d throws a Reference Error if you try to use it before it is initialized.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>console.log(hello); \/\/ReferenceError: Cannot access 'hello' before initialization\nlet hello = &quot;Hello, World&quot;;<\/pre><\/div>\n\n\n\n<p>Know that the let keyword is the better choice in terms of syntax. This is because errors are thrown where you might try to redeclare a variable or use it before the initialization process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ES6: Const<\/h2>\n\n\n\n<p>The <code>const<\/code> keyword has even stricter guidelines than the <code>let<\/code><em> <\/em>keyword. With <code>const<\/code>, variables cannot be redeclared or reassigned. A TypeError is thrown if you try to reassign to a <code>const<\/code>.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const HELLO = &quot;Hello, World&quot;;\nHELLO = &quot;Hello, Mars&quot;; \/\/TypeError: Assignment to constant variable.<\/pre><\/div>\n\n\n\n<p>That being said, when working with objects or arrays, properties of the object or array can be updated. As long as the basic structure of the object or array doesn\u2019t change, you can always update it.<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const business = {\n   &quot;id&quot;: 1,\n   &quot;name&quot;: &quot;Brainsphere&quot;,\n   &quot;website&quot;: &quot;http:\/\/walmart.com&quot;,\n   &quot;email&quot;: &quot;mhallad0@narod.jp&quot;\n }\n \n business.email = &quot;info@brainsphere.com&quot;; \/\/this is okay since we are updating property\n business.website = &quot;http:\/\/brainsphere.com&quot;;\n \n console.log(business);\n \n business = { \/\/ this is not okay since we are trying to reassign the entire object\n     &quot;id&quot;: 2,\n     &quot;name&quot;: &quot;Walmart&quot;,\n     &quot;website&quot;:  &quot;http:\/\/walmart.com&quot;,\n     &quot;email&quot;: &quot;info@walmart.com&quot;\n }\n \n console.log(business);<\/pre><\/div>\n\n\n\n<p>As shown in the example, reassigning business to a new set of properties results in a <code>TypeError: Assignment to constant variable. <\/code>error. Consts cannot be reassigned or redeclared except in cases where you update the individual property in an object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scope and Hoisting<\/h3>\n\n\n\n<p>Just like the <code>let<\/code> keyword, <code>const<\/code><em> <\/em>is block-scoped and is not initialized when hoisted so it will throw an error if you try to use it prior to initialization.<br><\/p>\n\n\n\n<p>The <code>const<\/code> keyword is great to use until you can\u2019t use it anymore. This is when you need to reassign or update your variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this article we went over the differences between <code>let<\/code>, <code>var<\/code>, and <code>const<\/code>. Out of all of the keywords available to us now, it\u2019s preferable to not use <code>var<\/code> unless you must. Use <code>let<\/code> or <code>const<\/code> instead.<\/p>\n","protected":false},"excerpt":{"rendered":"New features have been added to the JavaScript language with the release of ECMAScript6 (ES6). One such feature affects how we declare variables. With the addition of let and const, came all sorts of questions about when to use each of the variable declarations.\u00a0 In this post, we talk about each of the options, with&hellip;","protected":false},"author":77,"featured_media":23827,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-23825","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":null,"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>Let vs Var | Career Karma<\/title>\n<meta name=\"description\" content=\"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.\" \/>\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\/let-vs-var\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Let vs Var vs Const: What\u2019s the Difference?\" \/>\n<meta property=\"og:description\" content=\"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/let-vs-var\/\" \/>\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-10-07T18:22:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-20T15:44:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"681\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christina Kopecky\" \/>\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=\"Christina Kopecky\" \/>\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\\\/let-vs-var\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"Let vs Var vs Const: What\u2019s the Difference?\",\"datePublished\":\"2020-10-07T18:22:53+00:00\",\"dateModified\":\"2022-07-20T15:44:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/\"},\"wordCount\":866,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/image.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/\",\"name\":\"Let vs Var | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/image.jpg\",\"datePublished\":\"2020-10-07T18:22:53+00:00\",\"dateModified\":\"2022-07-20T15:44:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/image.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/image.jpg\",\"width\":1020,\"height\":681,\"caption\":\"Person using laptop\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/let-vs-var\\\/#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\":\"Let vs Var vs Const: What\u2019s the Difference?\"}]},{\"@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\\\/ae0cdc4a5d198690d78482646894074e\",\"name\":\"Christina Kopecky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"caption\":\"Christina Kopecky\"},\"description\":\"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.\",\"sameAs\":[\"http:\\\/\\\/www.linkedin.com\\\/in\\\/cmvnk\"],\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/christina-kopecky\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Let vs Var | Career Karma","description":"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.","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\/let-vs-var\/","og_locale":"en_US","og_type":"article","og_title":"Let vs Var vs Const: What\u2019s the Difference?","og_description":"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/let-vs-var\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-07T18:22:53+00:00","article_modified_time":"2022-07-20T15:44:04+00:00","og_image":[{"width":1020,"height":681,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg","type":"image\/jpeg"}],"author":"Christina Kopecky","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Christina Kopecky","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"Let vs Var vs Const: What\u2019s the Difference?","datePublished":"2020-10-07T18:22:53+00:00","dateModified":"2022-07-20T15:44:04+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/"},"wordCount":866,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/let-vs-var\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/","url":"https:\/\/careerkarma.com\/blog\/let-vs-var\/","name":"Let vs Var | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg","datePublished":"2020-10-07T18:22:53+00:00","dateModified":"2022-07-20T15:44:04+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"Learn about the differences between let, var, and const in this primer on variable declaration on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/let-vs-var\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/10\/image.jpg","width":1020,"height":681,"caption":"Person using laptop"},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/let-vs-var\/#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":"Let vs Var vs Const: What\u2019s the Difference?"}]},{"@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\/ae0cdc4a5d198690d78482646894074e","name":"Christina Kopecky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","caption":"Christina Kopecky"},"description":"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.","sameAs":["http:\/\/www.linkedin.com\/in\/cmvnk"],"url":"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23825","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\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=23825"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23825\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/23827"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}