Hello @Ariyaskumar
Yes indeed Array.from() method suggested by @Rashmihasija and spread syntax method by @devan-skeem we good ones. But I also had one, let me tell you about the same.
You could also loop through the Map manually and push objects into an array if that style suits your needs:
let myMap = new Map().set('a', 1).set('b', 2);
let arr = [];
for (let [name, value] of myMap) {
arr.push({ name, value: value.toString() });
}
console.log(arr);
While it’s a bit more verbose than the one-liners, this approach works perfectly and is especially useful if you want to add more logic during the iteration, such as conditional checks or transformations.
Hope this one works for you. Thankyou