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