Sunday, 21 October 2018

JavaScript: Map.prototype.set(key, value): Set the value for key

Map.prototype.set(key, value)
This method set the value for given key.

Find the below working application.

HelloWorld.js
var countriesMap = new Map();

countriesMap.set("Bahrain", "Manama");
countriesMap.set("Cameroon", "Yaounde");
countriesMap.set("Norway", "Oslo");
countriesMap.set("India", "New Delhi");

console.log("Is countriesMap has Norway : " + countriesMap.has("Norway"));
console.log("Is countriesMap has India : " + countriesMap.has("India"));
console.log("Is countriesMap has Australia : " + countriesMap.has("Australia"));


Output
Is countriesMap has Norway : true
Is countriesMap has India : true
Is countriesMap has Australia : false



Previous                                                 Next                                                 Home

No comments:

Post a Comment