JavaScript · Junior · Question 54 of 75
What does [1, 2].push(3) return?
- ✓Correct answer:
3- the new length of the array - 2
[1, 2, 3] - 3
undefined
Explanation
push mutates the array and returns its new length, a common source of bugs like arr = arr.push(x). For an immutable version use [...arr, x].