Javascript
Apr 11, 2026
What is the output?
const x = [1, 2, 3]
const y = x
y.push(4)
console.log(x.length)
Explanation
Arrays are reference types. y = x does not copy — both point to the same array in memory.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.