Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur.
SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
Ravi Vishwakarma
17-Jun-2024let,const, andvarkeywords are used for variable declarations, but they have some key differences in terms of scope, hoisting, and mutabilityvar:
varare function-scoped when declared inside a function, or globally scoped when declared outside any function.varare hoisted to the top of their scope and initialized withundefined. This means you can use avarvariable before it's declared in the code.varcan be redeclared and reassigned.let:
lethave block scope, which means they are only accessible within the nearest enclosing curly braces{ }.letare hoisted to the top of their block but are not initialized. This means you cannot access aletvariable before it's declared in the code.letcan be reassigned, but you cannot redeclare them in the same scope.const:
let, variables declared withconsthave block scope.constare also hoisted to the top of their block but are not initialized. You cannot access aconstvariable before it's declared.constmust be initialized with a value and cannot be reassigned to a different reference. However, their value may be mutable (e.g., properties of an object or elements of an array can be changed).