Day:4- JS let and const

Check console, Inspect ( Ctrl+Shift+I )

In JavaScript, let and const are two ways to declare variables, and they have different behaviors when it comes to reassignment and scope.

let

The let keyword allows you to declare variables that can be updated or reassigned later. as We can think of let as a flexible container – once we've stored a value in it, we can change that value and can be reassigned the value as needed throughout our program.

const

The const keyword is used to declare variables that are constant. Once we assign a value to a variable declared with const, we cannot reassign the value of that variable..

const important notes

This makes 'const' ideal for values that you don't want to change accidentally during the execution of your program.


In summary, use let when you need a variable that can be reassigned, and use const when you want to declare a variable that should not be reassigned.