How to convert a plain object into ES6 Map using JavaScript ? Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The task is to convert a JavaScript Object into a plain ES6 Map using JavaScript. we're going to discuss a few techniques. To understand the difference between a map and an object please go through the Map vs Object in JavaScript article. Below are the following approaches to converting a plain object into ES6 Map using JavaScript: Using map() Constructor and Object Entries MethodUsing Map() and forEach() MethodUsing Map() and reduce() MethodApproach 1: Using map() Constructor and Object Entries MethodCreate an object.Create a new map.Pass the object to the map and set its properties.Example: In this example, we will convert an object into a map using the object.entries method. JavaScript let obj = { prop_1: 'val_1', prop_2: 'val_2', prop_3: 'val_3' }; function GFG_Fun() { const map = new Map(Object.entries(obj)); console.log( "Val of prop_2 is " + map.get('prop_2')); } GFG_Fun() OutputVal of prop_2 is val_2 Approach 2: Using Map() and forEach() MethodIn this method, we will convert an object into a map by passing it to another function called createMap() and using the object.forEach() method Example: JavaScript let obj = { prop_1: 'val_1', prop_2: 'val_2', prop_3: 'val_3' }; function createMap(obj) { let map = new Map(); Object.keys(obj).forEach(key => { map.set(key, obj[key]); }); return map; } function GFG_Fun() { const map = createMap(obj); console.log( "Val of prop_1 is " + map.get('prop_1')); } GFG_Fun() OutputVal of prop_1 is val_1 Approach 3: Using Map() and reduce() MethodThe Javascript arr.reduce() method in JavaScript is used to reduce the array to a single value and executes a provided function for each value of the array (from left to right) and the return value of the function is stored in an accumulator. Example: JavaScript function convertObjectToMap(obj) { const map = Object.keys(obj).reduce((result, key) => { result.set(key, obj[key]); return result; }, new Map()); return map; } // Example plain object let obj = { prop_1: 'val_1', prop_2: 'val_2', prop_3: 'val_3' }; const mapFromObject = convertObjectToMap(obj); // Accessing Map values console.log(mapFromObject.get("prop_1")); console.log(mapFromObject.get("prop_2")); console.log(mapFromObject.get("prop_3")); Outputval_1 val_2 val_3 We have a complete list of Javascript ES6 features, to check those please go through this Introduction to ES6 article. Create Quiz Comment P PranchalKatiyar Follow 0 Improve P PranchalKatiyar Follow 0 Improve Article Tags : JavaScript Web Technologies javascript-object JavaScript-ES JavaScript-Questions +1 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like