5.
How do you initialize an array in JavaScript?
By using square brackets []
By using the Array() constructor
By using the new Array() syntax
By using the curly braces {}
Correct: A, B, C
Arrays in JavaScript can be initialized using square brackets [], the Array() constructor, or the new Array() syntax. For example:
const array1 = [1, 2, 3];
const array2 = Array(4, 5, 6);
const array3 = new Array(7, 8, 9); All three ways will create an array with the specified elements.