Map.prototype.has(key)
This
method returns true, if the map cotains given key, else false.
Find
the below working application.
var countriesMap = new Map(); countriesMap.set("Bahrain", "Manama"); countriesMap.set("Cameroon", "Yaounde"); countriesMap.set("Norway", undefined); 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
Is countriesMap has Australia : false
No comments:
Post a Comment