What will be the length of the array after [1, 2, 3].unshift(4, 5);?
- 2
- 3
- 4
- 5
The length of the array will be 5. The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array. In this case, it adds 4 and 5 to the beginning of the array, making it [4, 5, 1, 2, 3], so the length is 5.
Loading...
Related Quiz
- What value types can be used for case comparisons in a switch statement?
- What is the common problem addressed by using asynchronous code in JavaScript?
- When using a for...of loop with strings, each iteration will provide a single _______.
- The comparison operator _______ checks for inequality, considering type coercion.
- The method getElementById selects an element using its ______.