var keyword do in JavaScript?The var keyword declares a variable that can be used throughout its function or globally if declared outside a function.
var inside a function?It has function scope, meaning it is accessible anywhere inside the function where it is declared.
var in the same scope?Yes, variables declared with var can be redeclared in the same scope without error.
var variable inside a block like if or for?The variable is not block-scoped but function-scoped, so it is accessible outside the block within the function.
var variables?Hoisting means the variable declaration is moved to the top of its scope before code runs, so you can use the variable before its declaration but its value will be undefined until assigned.
var inside a function?Variables declared with var inside a function are accessible anywhere inside that function.
var variable in the same scope?Redeclaring a var variable in the same scope overwrites the previous declaration without error.
var variables and hoisting?With var, the declaration is hoisted to the top, but the assignment stays where it is.
var variable inside an if block, where can you access it?var variables are function-scoped, so they are accessible anywhere inside the function, not just inside the block.
var?let provides block scope, which var does not.
var variables behave with respect to scope and hoisting.var and let in terms of scope.