/* Hoisting:- Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope (to the top of the current script or the current function). That means a variable can be used before it has been declared. Variables and constants declared with let or const are not hoisted. JavaScript in strict mode does not allow variables to be used if they are not declared. A variable is a storage location for holding avalue. The set of permissible values is determined by the variable'stype. var, let, const:- These are the keywords used to create identifiers such variables. var:- var keyword lets us create a variable with the scope of current script or current function. The values of these identifiers can change at any time. let:- let keyword lets use create a variable with the scope of current script or current function and block scope. The values of these identifiers still can be changed at any time. const:- const keyword lets us create a variable with the scope of current script or current function and block scope. The values of these identifiers can’t be changed once it’s been initialised. Initialization of constant variables should happen when it’s been declared. */ // example for var keyword var fullname; function test() { // these variables can't bbe accessed outside of the test function var fname = "venkat" var lname = "b"; fullname = fname + " " + lname; } test(); console.log(fullname); // The extra feature that let has over var is block level scope // block leve scope can be added using {} or any other bblock level constructs // available in JavaScript { // example for ket keyword let fullname; let test = function () { let fname = "venkat"; let lname = "b"; fullname = fname + " " + lname; } test(); console.log(fullname); } // The extra feature that const has var is blocl level and value can't be changed { const fullname = "venkat b"; const test = function () { const fname = "venkat"; const lname = "b"; // we can't do this //fullname = fname + " " + lname; } test(); console.log(fullname); }