Horje
How to Create an Empty Map in JavaScript ?

In JavaScript, you can create an empty Map using the Map constructor. whenever we initialize any map it is empty at first and we need to declare the key-value pair inside the map constructor to construct the map having values.

Syntax:

let emptyMap = new Map();

Example: Here, initialMap is a Map that has been initialized with key-value pairs.

let initialMap = new Map([
['key1', 'value1'],
['key2', 'value2'],
// more key-value pairs if needed
]);



Reffered: https://www.geeksforgeeks.org


JavaScript

Related
How to Check the Size of a JavaScript Map ? How to Check the Size of a JavaScript Map ?
What is the use of the Map.prototype.keys method in JavaScript Maps ? What is the use of the Map.prototype.keys method in JavaScript Maps ?
What is the use of the Map.prototype.clear method in JavaScript Maps ? What is the use of the Map.prototype.clear method in JavaScript Maps ?
What is the use of the Get method in Maps in JavaScript ? What is the use of the Get method in Maps in JavaScript ?
Difference Between a Set and an Array Difference Between a Set and an Array

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13