JavaScript Map() Constructor Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The Map() constructor is used to create Map objects in JavaScript. The map is a data structure that stores elements as a key, value pair.Syntax:new Map()new Map(iterable)Parameters:iterable: An iterable object used for iterating through elements, stored as a key, value pair.Return value:A new Map object returns after the initialization of the map constructor. Example 1: JavaScript // map1 contains // 1 => 10 // 2 => 20 // 3 => 30 // 4 => 40 let map1 = new Map([ [1, 10], [2, 20], [3, 30], [4, 40] ]); console.log("Map1: "); console.log(map1); Output:Map1: Map(4) { 1 => 10, 2 => 20, 3 => 30, 4 => 40 }Example 2: JavaScript // map2 contains // firstname => Ram // lastname => Prasad // website => geeksforgeeks let map2 = new Map([ ["firstname", "Ram"], ["lastname", "Prasad"], ["website", "geeksforgeeks"] ]); console.log("Map2: "); console.log(map2); Output:Map2:Map(3) { 'firstname' => 'Ram', 'lastname' => 'Prasad', 'website' => 'geeksforgeeks'}Example 3: JavaScript // Map contains nested array let map3 = new Map([ ["whole numbers", [1, 2, 3, 4]], ["Decimal numbers", [1.1, 1.2, 1.3, 1.4]], ["negative numbers", [-1, -2, -3, -4]] ]); console.log("Map3: "); console.log(map3); Output:Map3:Map(3) { 'whole numbers' => [ 1, 2, 3, 4], 'Decimal numbers' => [ 1.1, 1.2, 1.3, 1.4], 'negative numbers' => [ -1, -2, -3, -4]}Supported Browsers:Chrome 38 Edge 12 Firefox 13Opera 25Safari 8 Comment More info A abhinavjain194 Follow Improve Article Tags : JavaScript Web Technologies javascript-map JavaScript-Methods 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 Strings6 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)9 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 readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like