Sitemap
Devmap

🚀 Everything You Need in One Place! . This page is your ultimate guide to development 💻 — from getting started 🛠️, building and testing your code 🧪, all the way to deployment 🚢 and monitoring 📈. And the best part? We’re just getting started — there’s more to come! 🔥

ES6+ Series

2 min readMay 12, 2025

--

ECMAScript 2019 introduced a few new built-in functions: flat and flatMap on Array.prototype for flattening arrays, trimStart and trimEnd on String.prototype, and Object.fromEntries for directly turning the return value of Object.entries into a new Object

Press enter or click to view image in full size

trimStart() and trimEnd()

Return a new string with removed white space from the start of the original string and end of the original string.

const one = "      hello and let's ";
const two = "begin ES6+ series. ";
console.log( one.trimStart() + two.trimEnd())
// "hello and let's begin ES6+ series ."

Array.flat()

Array.flat() returns a new array with any sub-array(s) flattened. A call to Array.flat() without any arguments will only flatten one-level deep. An optional depth argument can be provided or it can just be called consecutively.

let arr = [1, 2, 3, [4, 5, 6, [7, 8, 9, [10, 11, 12]]]];
arr.flat(); // [1, 2, 3, 4, 5, 6, Array(4)];
arr.flat().flat(); // [1, 2, 3, 4, 5, 6, 7, 8, 9, Array(3)];
arr.flat(3); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// Or, if you're not sure about the depth of the array:
arr.flat(Infinity); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Array.flatMap()

--

--

Harsha
Harsha

Written by Harsha

Frontend Developer exploring JavaScript, React, browser APIs, and web performance. Sharing practical insights, tutorials, and real-world frontend techniques.

Devmap
Devmap

Published in Devmap

🚀 Everything You Need in One Place! . This page is your ultimate guide to development 💻 — from getting started 🛠️, building and testing your code 🧪, all the way to deployment 🚢 and monitoring 📈. And the best part? We’re just getting started — there’s more to come! 🔥