Javascript
Apr 21, 2026
What is arr.flat().length?
const arr = [1, [2, [3, [4]]]]
console.log(arr.flat().length)
Explanation
flat() only flattens ONE level deep by default.
📝
Reviewed by CodeShot Editorial
Every challenge is code-reviewed by senior developers to ensure accuracy and real-world relevance. Learn more.