const stands for constant, and it means the variable cannot be reassigned at a later time.

let is similar to var except that it is block scoped, which means it can be declared inside of a for loop and will be local to the body of that for loop (and therefor does not exist outside of it)

The latter is different from a var variable which can be declared anywhere but is always local to the function scope.

In general it is good practice to try and define your variables as const as much as possible.

Answer from vileRaisin on Stack Overflow
🌐
Medium
medium.com › @robinviktorsson › understanding-the-differences-between-var-let-and-const-in-javascript-and-typescript-0ddd90c0b672
Understanding the Differences Between var, let, and const in JavaScript and TypeScript 💻 | by Robin Viktorsson | Medium
March 10, 2025 - ... Use var only if you are working ... rare in modern JavaScript/TypeScript). Use let when you need a block-scoped variable that can be reassigned, especially within loops or conditions....
Discussions

Benefit of const vs let in TypeScript (or Javascript) - Stack Overflow
I was reading the TypeScript Deep Dive and I see that both let and const are block scoped, which is great. Obviously, a const cannot be changed (it is immutable). But why is ReSharper is encouraging me to change as many lets to const as I can? I'm assuming ReSharper thinks there is a performance gain in using const over let? Is there a speed difference between const and let? Is there a different reason to use const? Take the following example... More on stackoverflow.com
🌐 stackoverflow.com
var, const, let
Rule of thumb: start with const, if you need to change the value later, change to let, and forget about var. More on reddit.com
🌐 r/typescript
23
9
April 24, 2018
JS <> const vs let = should I always use const?
It's not a matter of preference, rcommended, or ideal programming style. const and let have their own purpose. One is not absolute better than the other. It would depend on whether the contained (direct) value may be changed or not; or whether it needs to be protected from being changed or not - either by your own code, or by others' code which you don't have control of. If neither doesn't matter, there's no difference betwen using const or let. More on reddit.com
🌐 r/learnprogramming
14
8
November 6, 2022
When should I use "var", "let" and "const" in TypeScript - Stack Overflow
85 What is the difference between var and let in Typescript? ... 2 In TypeScript, is there a reason to prefer const foo: Type = {...} or const foo = { ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Tektutorialshub
tektutorialshub.com › home › typescript › typescript let vs var vs const
Typescript Let vs Var vs Const - Tektutorialshub
March 15, 2023 - You can learn more about the variable declaration from Typescript variables tutorial. There are four ways you can declare a variable. They are ... Use var and let to define any variable, with or without type or initial value. We use the const keyword initialize a constant whose value does not change.
🌐
TypeScript
typescriptlang.org › docs › handbook › variable-declarations.html
TypeScript: Documentation - Variable Declaration
In other words, they have the same scoping rules as let, but you can’t re-assign to them. This should not be confused with the idea that the values they refer to are immutable. ... Unless you take specific measures to avoid it, the internal state of a const variable is still modifiable. Fortunately, TypeScript ...
Top answer
1 of 2
56

I agree with Giorgi that performance is not the main reason. A code analyzer could just as well determine that a variable declared with let is not ever reassigned and optimize it the same as if you had declared it with const. (Heck, linters have rules to detect this and suggest using const instead of let.)

Yes, it does signal to the reader that you're not going to assign to the variable. The benefit of const, over putting a comment saying the same thing, is mainly that const is a standard way of signalling it. Being standard, it transmits the information more readily than custom comments. (Also, a comment could be wrong but const won't let you be wrong.) I don't think this is the main benefit though.

The "principle of least privilege" is often invoked in conjunction with const, but why should I care about the least privilege? Because it helps with early detection of coding mistakes. Consider the following code:

function findSomethingInDocument(document) {
    let tree = getTreeFromDocument(document); // We get some sort of tree structure.
    let found;
    for (const child of tree.children) {
        if (child.someFlag) {
            tree = child; // Oops I meant found = child :(
            break;
        }
    }
    return found;
}

In this code, I typed tree = child when I meant to type found = child. Yes, the bug can be found in testing. But why wait for testing? I never meant tree to be changed. If I had marked it const then I would have immediately learned the error because the compiler would informed me of it. I would not have to wait for testing. The code above is fairly simple but imagine a more complicated algorithm that uses more variables.

2 of 2
16

When you have a variable which can be declared as const, and you declare it as such you inform the reader that you don't plan to reassign it to a different value later on.

Also by declaring a variable const it means you have thought up front that you don't plan to reassign it, which in turn can protect you from accidental bugs or errors.

🌐
Tutorial Teacher
tutorialsteacher.com › typescript › typescript-variable
TypeScript Variable Declarations: var, let, const
Learn the different ways of declaring variables in TypeScript using var, let and const keywords.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › home › typescript › typescript let and const
TypeScript let and const
December 18, 2016 - The output of the above example code is as follows ... The 'const' keyword has the same syntax as 'var' and 'let' to declare variables. It is used to declare the constant variables. Furthermore, you need to initialize the 'const' variables while defining them, and you can't change them later. The syntax to declare a variable using the 'const' keyword in TypeScript ...
🌐
Medium
medium.com › @iamsounak01 › understanding-let-const-and-var-in-typescript-a-beginners-guide-with-examples-e99ab6c6fc62
Understanding let, const, and var in TypeScript: A Beginner's Guide with Examples | by Sounak Das | Medium
November 8, 2024 - When writing TypeScript (or JavaScript) code, you’ll often see three keywords used to declare variables: let, const, and var. Although they might seem similar, each serves a unique purpose and behaves differently in specific contexts. In this guide, we’ll break down these differences with easy-to-understand examples and explain when to use each one.
🌐
Total TypeScript
totaltypescript.com › let-and-const
How let and const Work In TypeScript | Total TypeScript
February 26, 2024 - Cannot assign to 'albumGenre' because it is a constant.2588Cannot assign to 'albumGenre' because it is a constant. TypeScript is mirroring JavaScript's treatment of const in order to prevent possible runtime errors.
🌐
freeCodeCamp
freecodecamp.org › news › var-let-and-const-whats-the-difference
Var, Let, and Const – What's the Difference?
April 2, 2020 - Therefore, if we declare a const object as this: ... This will update the value of greeting.message without returning errors. Just like let, const declarations are hoisted to the top but are not initialized.
🌐
Home
javahabit.com › typescript-variable-let-var-const
TypeScript's Variable Wars: Battle of let vs. const vs. var – Which One Wins?
May 28, 2023 - Consider the following example: In this case, an attempt to access the message variable before its declaration results in a ReferenceError, clearly indicating that variables declared with let must be defined before they are used. The const declaration in TypeScript serves a specific purpose: defining immutable variables that hold constant values.
🌐
Gazar
gazar.dev › typescript › when-to-use-let-vs-const
When to Use let vs const in TypeScript | Gazar
The let keyword is used to declare variables that can be reassigned. It is block-scoped, meaning the variable is only accessible within the block it was declared in. let counter = 0; if (true) { let counter = 1; console.log(counter); // Output: 1 } console.log(counter); // Output: 0
🌐
Mimo
mimo.org › glossary › typescript › const
TypeScript Const: Syntax, Usage, and Examples
In TypeScript, both const and let are block-scoped, but they serve different purposes. Use const when you don’t intend to reassign the variable after its initial declaration. It signals that the binding should remain fixed, which helps prevent bugs related to accidental reassignment. On the other hand, use let when you do need to update the variable’s value later—for example, in loops or conditional logic.
🌐
Fireship
fireship.dev › var-let-const
var vs let vs const in JavaScript
If it will need to change (like in a for loop), you should use let. So between variables that change and variables that don't change, there's not much left. That means you shouldn't ever have to use var again.
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › difference between let, var and const
Difference between let, var and const in JavaScript
September 22, 2021 - Variables declared by var and const keywords are function scoped and are scoped to the immediate function body. Also, variables declared with var keyword are hoisted (initialized with undefined before the code is run) which means they are accessible in their enclosing scope even before they are declared. Variables declared by let keyword are block scoped and are scoped to the immediate enclosing block.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › difference-between-var-let-and-const-keywords-in-javascript
Difference between var, let and const keywords in JavaScript - GeeksforGeeks
let: Declares variables with block scope, allowing updates but not re-declaration within the same block. const: Declares block-scoped variables that cannot be reassigned after their initial assignment.
Published   January 16, 2026