Single Choice
Difficult
QWhat is the result of the following code?
var map = new Map();
map.set(1, "one");
map.set(2, "two");
console.log(map.size);
ID: #4904
Javascript Data Types MCQ
350 views
Question Info
#4904Q ID
DifficultDifficulty
Javascript Data Types MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
The Map data type in JavaScript is a constructor that creates a new map object, which is a collection of key-value pairs.
The set method is used to add a new key-value pair to the map object.
In this case, two key-value pairs are added to the map object using the set method.
The size property is used to get the number of key-value pairs in the map object.
Since there are 2 key-value pairs in the map object, the size property will return 2.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic