2.
Which of the following is the correct way to declare an array in JavaScript and initialize it with values?
var arr = [1, 2, 3];
var arr = array[1, 2, 3];
var arr = [1, 2, 3,];
var arr = {1, 2, 3};
Correct: A
The correct way to declare and initialize an array in JavaScript is by using the [] shorthand notation and specifying the values inside the brackets. Option A is the correct choice where an array is declared and initialized with the values 1, 2, and 3. The other options are all incorrect syntax for declaring an array in JavaScript.