JavaScript Map set() methodLast Updated : 17 Mar 2025 The JavaScript map set() method is used to add or updates an element to map object with the particular key-value pair. Each value must have a unique key. SyntaxThe set() method is represented by the following syntax: Parameterkey - It represents the key to be added. value - It represents the value to be added. ReturnThe Map object. JavaScript Map set() method exampleHere, we will understand set() method through various examples. Example 1Let's see an example to add key and value pair of elements to map object. Output: jQuery AngularJS Bootstrap Example 2In this example, we will determine the result when same key is added with different values. Output: AngularJS undefined Bootstrap Next TopicJavaScript Map |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India