let arr = [1, [2, [3, [4, 5], 6], 7, 8], 9, 10];
let flatArrOne = arr.flat();
"Array flattened to depth of 1:"
let flatArrTwo = arr.flat(2);
"Array flattened to depth of 2:"
let flatArrThree = arr.flat(Infinity);
"Array flattened completely:"
Original Array: [ 1, [ 2, [ 3, [Array], 6 ], 7, 8 ], 9, 10 ]
Array flattened to depth of 1:1,2,3,4,5,6,7,8,9,10
Array flattened to depth of 2:1,2,3,4,5,6,7,8,9,10
Array flattened completely:1,2,3,4,5,...
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!