Vanshika Pandey

Do you know what the output of this code will be?


let array = [1, 2, 3];
array[6] = 9;
console.log(array[5]);

9 months ago | [YT] | 21



@rakshitkakar2603

Undefined, it's the default value if no value is explicitly defined to an element in an array in js and also in the 2nd statment it won't throw an error in js it will increase the size of array

9 months ago (edited) | 4

@HaAriomOP

Undefined 👍

9 months ago | 1

@Kartikgangil

Undefined, because array only contain 3 elements

9 months ago (edited) | 2

@rabindranathlodha

Undefined

9 months ago | 0