You are here: Home / Topics / Difference between var and let keyword in javascript

Difference between var and let keyword in javascript

Filed under: JavaScript Interview Questions on 2022-07-03 08:02:19

Some differences are 

  1. From the very beginning, the 'var' keyword was used in JavaScript programming whereas the keyword 'let' was just added in 2015.
  2. The keyword 'Var' has function scope. Anywhere in the function, the variable specified using var is accessible but in ‘let’ the scope of a variable declared with the 'let' keyword is limited to the block in which it is declared. Let's start with a Block Scope.
  3. 'var' declares a variable that will be hoisted but 'let' declares a variable that will not be hoisted.
About Author:
M
Monu Rathod     View Profile
Giving someone what you have is great deed.