What I Wish Every Developer Knew About let In Javascript

What I Wish Every Developer Knew About let In Javascript

One of the greatest things introduced in ES6 was the `let` variable initialization. Why is it better then `var`? Let's see.

One of the most widely used elements introduced in ES6 is the let variable initialization. Why is it better then var? Let's see.

The main similarity is that var and let allow you to initialize a variable without assigning a value. Afterwards, you can update and change that value.

let value;

value = 'string';

value = 1;


// 1

And that's where the similarities end.

1. Block scope

function sayWhaaaat() {
    for(var i = 0; i < 4; i++) {
        var value = i;


// 3

What's going on above? We declare using var a variable called value. And we can access it outside the block! If you try you will be able to console.log the i as well.

Initializing all variables using let will prevent similar issues as let is truly block scoped! When you replace the var with let and try to access it you will get Uncaught ReferenceError: value is not defined.

javascript es6 programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Taking functional programming to JavaScript objects

Functional programming seems to be where the hype is nowadays — And for good reason; It can drastically reduce the amount of boilerplate code that you have to write in comparison to imperative programming which allows you to improve the readability of your code and consequently, maintainability.

JavaScript: ES6 & Beyond

ECMAScript 2015 (ES6) is a major update to Javascript since ES5 which was standardized in 2009. These significant updates from ES6 and beyond are commonly referred to as Modern Javascript.

JavaScript: Template Literals (ES6)

Beginners Guide to Template Literals in JavaScript. JavaScript: Template Literals (ES6). Inthis article, I will discuss another powerful feature of modern JavaScript; template literals, which was released in the 2015 edition of the ECMAScript specification and was referred to as template strings prior to ES6. Similar to string interpolation features in other languages like Ruby and Phyton, template literals provide syntactic sugar that allows us to construct strings more quickly. Before template literals were added to the JavaScript language in ES6, single quotes (‘ ’) and double quotes (“ ”) were the only ways to make a string. Template literals offer another way to declare strings that makes use of backtick (` `) character.

JavaScript Spread Operator (ES6 Tutorial)

Learn JavaScript Spread Operator (ES6 Tutorial). Using the spread operator in JavaScript (ES6) can be helpful in our daily programming lives. we are going to talk about the JavaScript Spread Operator, what it does, how to use it with some examples including arrays, objects, and functions.

Learn Javascript | Intro to programming

Learn Javascipt programming language. This is introduction to programming and Javascript. For more programming videos: ♥ Subscribe: https://www.youtube.com/c...