Question:medium

Predict the output of the following JavaScript code:
var colors = ['Red', 'Blue', 'Green'];
document.write(colors.pop() + "
");
document.write(colors.push('Yellow') + "
");
document.write(colors.join('& amp;') + "
");
document.write(colors.slice(1, 3));

Show Hint

Remember: pop() returns the removed element, but push() returns the new length (a number) of the mutated array.
Updated On: Jun 29, 2026
Show Solution

Solution and Explanation

Was this answer helpful?
0