I am new to javascipt as I have started learning js now, I am pretty confused with var
that is said to be function scoped and block scoped;
If so then how do we access them outside of that function!? lets say i want to use it from another class (I don't know maybe by creating some object or whatever) (I guess we can't create objects here! because as it is a functional programming based language I guess!:( )
var y = "global";
if (y === "global") {
var y = "block-scoped";
console.log(y); // expected output: block-scoped
}
console.log(y); // expected output: block-scoped