+ 1

What does these codes do ?

var a = 1; var num = [2, 3, 4, 5, 6, 7, 8]; console.log(num[a++]); and var a = 1; var num = [2, 3, 4, 5, 6, 7, 8]; console.log(num[++a]);

1st Mar 2020, 8:40 AM
Marina Khamis
Marina Khamis  - avatar
1 Answer
+ 6
a = 1 a++ => 1 num[1] => 3 a = 1 ++a => 2 num[2] => 4 pre increment post increment
1st Mar 2020, 8:44 AM
Gordon
Gordon - avatar