Quick actions

cmd+k|ctrl+k

Navigation

Languages

Variable Scope and Let Keyword

Snippet info

Language

JavaScript

Visibility

public

Author

sanjivrai543

Created

2020-10-26T22:02:00Z

Updated

2020-10-26T22:02:00Z

console.log("Hello World!");
/* the variable i seems to be a global varaible becoz of the eection style of the javascript code
first it will create the variable i like var i; outside of the loop which makes it global
also due to this scope of the i is not bound to for loop 


for(var i=0;i<10;i++)
{
    console.log(i);
}
console.log(i);
*/
//therefore to tackle this issue let keyword is being introduced
for(let i=0;i<10;i++)
{
    console.log(i);
}
//console.log(i);
INFO