Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert map to object/JSON javascript

const map1 = new Map([
  ['foo', 'bar'],
  ['baz', 42]
]);

const obj = Object.fromEntries(map1);
// { foo: 'bar', baz: 42 }

//To get back the map:
const map2 = new Map(Object.entries(obj));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #map #javascript
ADD COMMENT
Topic
Name
8+1 =