JavaScript · Junior · Question 54 of 75

What does [1, 2].push(3) return?

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].

Further reading

Problem with a question

JavaScript · Junior · question 54

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz