Map ऑब्जेक्ट का has() फंक्शन स्ट्रिंग फॉर्मेट में एक की स्वीकार करता है और एक बूलियन मान लौटाता है, यदि निर्दिष्ट की मौजूद है तो यह true लौटाता है अन्यथा false।
सिंटैक्स
इसका सिंटैक्स निम्नानुसार है:
mapVar.has(key)
उदाहरण
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var mapVar = new Map(); mapVar.set('1', 'Java'); mapVar.set('2', 'JavaFX'); mapVar.set('3', 'HBase'); mapVar.set('4', 'Neo4j'); document.write(mapVar.has('3')); </script> </body> </html>
आउटपुट
true
उदाहरण
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var mapVar = new Map(); mapVar.set('1', 'Java'); mapVar.set('2', 'JavaFX'); mapVar.set('3', 'HBase'); mapVar.set('4', 'Neo4j'); document.write(mapVar.has('19')); </script> </body> </html>
आउटपुट
false