program to state difference between Var, Let and Const:
// let
let a = 10
console.log(a)
{
let a= 100
console.log(a)
}
console.log(a)
//var :- rarely used
var b = 20
console.log(b)
{
var b= 100
console.log(b)
}
console.log(b)
//const
const pi = 3.14
console.log(pi)
{
// let pi =0 const can't be declared again but value can be changed
const pi= 3.142
console.log(pi)
}
console.log(pi)
Output:
No comments:
Post a Comment