+ 2

Imagine you have an empty JavaScript array (list=[ ]), If you insert 9 in position 0, 3 in position 1, and then 8 in position 0

Imagine you have an empty JavaScript array (list=[ ]), If you insert 9 in position 0, 3 in position 1, and then 8 in position 0 again, what do you get when you print the list to the console ?

30th Apr 2018, 1:54 PM
shadrach esharive
shadrach esharive - avatar
2 ответов
+ 4
list = [] list[0] = 9 //list = [9] list[1] = 3 // list = [9, 3] list[0] = 8 //list = [8, 3] Inserting items at specific position this way replaces the previous element present in that position from the array with the new one.
30th Apr 2018, 2:19 PM
Lord Krishna
Lord Krishna - avatar
0
i think [9, 3, 8] oops i read bad sorry
30th Apr 2018, 2:03 PM
Etabeta1🇮🇹
Etabeta1🇮🇹 - avatar