A Javascript map is a collection of elements where each element is stored as a Key, value pair. Map objects can hold both objects and primitive values as either key or value. When we iterate over the map object it returns the key, and value pair in the same order as inserted.
Syntax:
let map = new Map([iterable]);
Parameter: It is any iterable object whose values are stored as a key, or value pair, If the parameter is not specified then a new map is created as Empty.
Example: Here is the basic example of a Javascript Map.
Javascript
let map1 = new Map([ [ "firstname" , "Rohit" ], [ "lastname" , "Sharma" ], [ "website" , "neveropen" ] ]); console.log(map1); |
Output:
Map(3) {'firstname' => 'Rohit', 'lastname' => 'Sharma', 'website' => 'neveropen'}
The following javascript section contains a wide collection of Javascript Date Objects examples. Many of these program examples offer different ways to handle the issue.
- How to serialize a Map in JavaScript?
- How to iterate over Map elements in JavaScript?
- How are elements ordered in a Map in JavaScript?
- What is JavaScript Map and how to use it?
- How to sort a map in JavaScript?
- How to map array values without using map method in JavaScript?
- What is the difference between Map and WeakMap in JavaScript?
- How to convert Map keys to an array in JavaScript?
- How to convert a plain object into ES6 Map using JavaScript?
- How to use map() on an array in reverse order with JavaScript?
- How to use map and filter simultaneously on an array using JavaScript?
- How to copy a map to another map in Golang?
- How to use map(), filter(), and reduce() in JavaScript?
- How to map an array in Coffeescript?
- Difference between forEach() and map() loop in JavaScript
- How to skip over an element in .map()?
- How to switch CSS class between buttons rendered with map()?
- How to call the map method only if the element is an array?
- JavaScript Index inside map() Function
We have a complete list of Javascript Map Programming, to check those, please go through this Javascript Map Complete Reference article.
We have created a complete JavaScript Tutorial to help both beginners and experienced professionals. Please check this JavaScript Tutorial to get the complete content from basic syntax and data types to advanced topics such as object-oriented programming and DOM manipulation.
We have created an article on JavaScript Examples and added a list of questions based on Array, Object, Function, …, etc. Please visit this JavaScript Examples to get a complete questions-based articles list of JavaScript.