Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

What does Array.push() return in JavaScript?

Do you know what will be the output of this code?

JavaScript
const arr = [1, 2];
const result = arr.push(3);
console.log(result);
Show answer and explanation

The answer is 3.

push() adds items to the end of the array and returns the new length. The array itself is changed in place, so arr is now [1, 2, 3].

Take the full quiz Next question →

More Basics questions

  1. What happens when you reassign a const in JavaScript?
  2. Why is typeof null "object" in JavaScript?
  3. What is the difference between == and === in JavaScript?
  4. Is a var loop variable accessible after a for loop?
  5. Why does "5" * "2" equal 10 in JavaScript?

Related topics