From 49740d77385622c3938138422430dbab385bc3ae Mon Sep 17 00:00:00 2001 From: vishwa-radhya Date: Sat, 21 Mar 2026 22:29:20 +0530 Subject: [PATCH] Docs: clarify usage of const,let and var in JavaScript variables --- tutorials/learn-js.org/en/Variables and Types.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tutorials/learn-js.org/en/Variables and Types.md b/tutorials/learn-js.org/en/Variables and Types.md index b1b67badf..51521d6df 100644 --- a/tutorials/learn-js.org/en/Variables and Types.md +++ b/tutorials/learn-js.org/en/Variables and Types.md @@ -9,6 +9,16 @@ We can define several types of variables to use in our code: const myString = "Hello, World!" // a string const myBoolean = true; // a boolean +**Note:** + +Although older JavaScript code uses `var` to declare variables, modern JavaScript prefers `let` and `const`. + +- `var` has function scope and can lead to confusing behavior in some cases. +- `let` is block-scoped and can be reassigned. +- `const` is block-scoped and cannot be reassigned, making it safer for values that should not change. + +For this reason, it is recommended to use `const` by default, and `let` only when you need to reassign a variable. + A few notes about variable types in JavaScript: * In JavaScript, the Number type can be both a floating point number and an integer.