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.
var
is scoped to the nearest function block while let
is scoped to the nearest enclosing block.var
allows redeclaration of a variable in the same block while let
doesn't.let
or const
are not hoisted.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.
Using "use strict" prevents you from using undeclared variables.