Object.fromEntries
JS
S
JavaScriptES2019 new feature - Transforms array [key, value] and List [key,value] into a literal object
1const map = new Map().set("id", 1).set("name", "John");
2const arr = [["id", 1], ["name", "John"]];
3const mapObj = Object.fromEntries(map);
4const arrObj = Object.fromEntries(arr);
5console.log(mapObj); // {id: 1, name: ‘John’}
6console.log(arrObj); // {id: 1, name: ‘John’}Created on 4/17/2019