Skip to content

Commit 740a49b

Browse files
committed
var let const 3 major diff
1 parent 2a27c0a commit 740a49b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

revision/rev2.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//var const let
2+
3+
let a=5
4+
var b=1
5+
const c=3
6+
7+
console.log("original values",a,b,c)
8+
a=6
9+
b=2
10+
// c=4
11+
console.log("updated values",a,b,c)//giving error bc of c
12+
13+
function abcd(){
14+
var d=3 //function scoped
15+
16+
17+
18+
if(1){
19+
const e=4
20+
let f=5 // braces scoped
21+
console.log(e,f,d)
22+
}
23+
console.log(e,f)
24+
25+
}
26+
abcd()
27+
28+
29+
// var add itself in window obj which is highly insecure for data privacy thats why let and const
30+
//were introduced which if defined in script.js will not add themself in window obj

0 commit comments

Comments
 (0)