In JavaScript, consider the statement: SubscriptionCost = new Array(3); Which…
2022
In JavaScript, consider the statement:
SubscriptionCost = new Array(3);
Which statement is incorrect about the above statement?
- A.
It creates an array whose length is initially 3
- B.
It creates a fixed-size array of 3 elements that cannot be resized
- C.
The initial valid index positions are 0, 1, and 2
- D.
The array can later grow beyond length 3 if values are assigned or elements are added
Attempted by 154 students.
Show answer & explanation
Correct answer: B
Key idea: With one numeric argument, new Array(3) creates an array whose length is 3 and whose slots are initially empty.
JavaScript arrays are dynamic; they are not fixed-size arrays.
The initial valid index positions are 0, 1, and 2.
The array can later grow if values are assigned beyond the current length or elements are added by array methods.
Correct answer: The statement claiming a fixed-size array that cannot be resized is incorrect.
A video solution is available for this question — log in and enroll to watch it.