Interview GURU

What is the use of a Map object in JavaScript?

The JavaScript Map object is used to map keys to values. It stores each element as key-value pair. It operates the elements such as search, update and delete on the basis of specified key. For example:

function test()  
{  
var map=new Map();    
map.set(1,"jQuery");    
map.set(2,"AngularJS");    
map.set(3,"Bootstrap");    
document.writeln(map.get(1)+"<br>");    
document.writeln(map.get(2)+"<br>");    
document.writeln(map.get(3));    
}  
test();