var:
Here var keyword has local scope and printing 11 after for loop.
for( var i=0; i<=10; i++)
{
console.log(i)
}
console.log(i)
Let
let keyword has blocked scope. Hence it gave error in below code
for( let j=0; j<=10; j++)
{
console.log(j)
}
console.log(j)
No comments:
Post a Comment