Map অবজেক্টের delete() ফাংশনটি একটি কী গ্রহণ করে এবং সেটি ম্যাপ থেকে মুছে ফেলে। যদি কীটি ম্যাপে থাকে তবে true রিটার্ন করে, অন্যথায় false।
সিনট্যাক্স
mapVar.delete(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'); var map = mapVar.delete('4'); document.write("Size of the map object: "+mapVar.size); </script> </body> </html>
আউটপুট
Size of the map object: 3
আরও উদাহরণ
<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'); var map = mapVar.delete('4'); document.write(map); document.write("<br>"); document.write("Size of the map object: "+mapVar.size); document.write("<br>"); var map = mapVar.delete('5'); document.write(map); document.write("<br>"); document.write("Size of the map object: "+mapVar.size); </script> </body> </html>
আউটপুট
true Size of the map object: 3 false Size of the map object: 3