কম্পিউটার টিউটোরিয়াল

জাভাস্ক্রিপ্ট Array.prototype.values() মেথড

জাভাস্ক্রিপ্টের array.values() মেথড একটি নতুন অ্যারে ইটারেটর অবজেক্ট রিটার্ন করে যাতে অ্যারের প্রতিটি ইনডেক্সের ভ্যালু থাকে।

সিনট্যাক্স:

arr.values()

উদাহরণ ১

<!DOCTYPE html>
<html>
<body>
  <h2>Demo Heading</h2>
  <p>Click the button to display the value...</p>
  <button onclick="display()">Result</button>
  <p id="test"></p>
  <script>
    function display() {
      var arr = ['p', 'q', 'r'];
      var res = arr.values();
      document.getElementById("test").innerHTML = res.next().value;
    }
  </script>
</body>
</html>

আউটপুট

প্রথম ভ্যালু 'p' দেখাবে।

উদাহরণ ২

<!DOCTYPE html>
<html>
<body>
  <h2>Ranking Points</h2>
  <p>Click to display the points...</p>
  <button onclick="display()">Result</button>
  <p id="test"></p>
  <script>
    function display() {
      var points = ['10', '20', '30', '40', '50'];
      document.getElementById("test").innerHTML = (points.values()).next().value;
    }
  </script>
</body>
</html>
  1. জাভাস্ক্রিপ্টে Array.prototype.flatMap() মেথড

  2. জাভাস্ক্রিপ্টে Array.prototype.includes() মেথড

  3. জাভাস্ক্রিপ্টে Array.prototype.sort() মেথড

  4. জাভাস্ক্রিপ্টে Array.prototype.flat() মেথড