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

জাভাস্ক্রিপ্ট Array.of() ফাংশন

জাভাস্ক্রিপ্টের Array.of() মেথড প্যারামিটার ভ্যালু হিসেবে ভেরিয়েবল দিয়ে একটি নতুন অ্যারে ইনস্ট্যান্স তৈরি করতে ব্যবহৃত হয়।

সিনট্যাক্স:

Array.of(elements....)

এখানে elements হলো প্যারামিটার ভ্যালু হিসেবে মানগুলো।

উদাহরণ

<!DOCTYPE html>
<html>
<body>
  <h2>Demo Heading</h2>
  <p>Click the button to display the values in Console</p>
  <button onclick="display()">Result</button>
  <p id="test"></p>
  <script>
    function display() {
      console.log(Array.of(10, 20, 30, 40, 50));
    }
  </script>
</body>
</html>

আউটপুট

কনসোলে [10, 20, 30, 40, 50] দেখাবে।

উদাহরণ ২

<!DOCTYPE html>
<html>
<body>
  <h2>Demo Heading</h2>
  <p>Get the student names with top 5 ranks...</p>
  <button onclick="display()">Result</button>
  <p id="test"></p>
  <script>
    function display() {
      console.log(Array.of("Kevin", "Tom", "Ryan", "Jacob", "Jack"));
    }
  </script>
</body>
</html>
  1. জাভাস্ক্রিপ্ট array.toLocaleString() ফাংশন

  2. জাভাস্ক্রিপ্ট Array findIndex() ফাংশন

  3. জাভাস্ক্রিপ্ট Array some() ফাংশন

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