JavaScript

JavaScript also is known as JS is a client-side programming language that runs on browsers. JavaScript is used in the web application to make applications faster & user interactive.

There are mainly 4 major differences between var & let.

  1. Scoping - var is scoped to the nearest function block while let is scoped to the nearest enclosing block.
  2. Redeclarations -var allows redeclaration of a variable in the same block while let doesn't.
  3. JavaScript Hoisting - Variables and constants declared with let or const are not hoisted.
  4. Global Window Object - Global variables declared with let are not added as property on the global window object.

Hoisting is the default behavior of JavaScript that moves all variable declarations to the top of the current scope. The scope may be the current script of the current function.

JavaScript Declarations are Hoisted. It means a variable can be used before it has been declared.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. For more information - please visit our private policy.