কম্পিউটার

জাভাস্ক্রিপ্টে Map.clear() ফাংশন


ম্যাপ অবজেক্টের ক্লিয়ার() ফাংশন বর্তমান ম্যাপ অবজেক্ট থেকে সমস্ত উপাদান সরিয়ে দেয়।

সিনট্যাক্স

এর সিনট্যাক্স নিম্নরূপ

mapVar.clear()

উদাহরণ

<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.clear();
      document.write("Size of the map object: "+mapVar.size);
   </script>
</body>
</html>

আউটপুট

Size of the map object: 0

উদাহরণ

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var mapVar = new Map();
      mapVar.set('1', 'Raju');
      mapVar.set('2', 'Ram');
      mapVar.set('3', 'Rahim');
      mapVar.set('4', 'Robert');
      document.write("Size of the map: "+mapVar.size);
      var map = mapVar.clear();
      document.write("<br>");
      document.write("Size of the map after clearing its contents using clear() function: "+mapVar.size);
   </script>
</body>
</html>

আউটপুট

Size of the map: 4
Size of the map after clearing its contents using clear() function: 0

  1. জাভাস্ক্রিপ্ট নম্বর ফাংশন

  2. জাভাস্ক্রিপ্টে ম্যাপ অবজেক্ট।

  3. জাভাস্ক্রিপ্টে ফাংশন প্রোটোটাইপ

  4. জাভাস্ক্রিপ্টে ফাংশন ধার করা।