কম্পিউটার

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


TypedArray অবজেক্টের copyWithin() ফাংশন এই TypedArray-এর বিষয়বস্তু নিজের মধ্যেই কপি করে। এই পদ্ধতিটি তিনটি সংখ্যা গ্রহণ করে যেখানে প্রথম সংখ্যাটি অ্যারের সূচীকে উপস্থাপন করে যেখানে উপাদানগুলির অনুলিপি শুরু করা উচিত এবং পরবর্তী দুটি সংখ্যা অ্যারের শুরু এবং শেষ উপাদানগুলিকে প্রতিনিধিত্ব করে যেখান থেকে ডেটা অনুলিপি করা উচিত (গ্রহণ করা)৷

সিনট্যাক্স

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

obj.copyWithin(3, 1, 3);

উদাহরণ

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55 ]);
      document.write("Contents of the typed array: "+int32View);
      int32View.copyWithin(5, 0, 5);
      document.write("<br>");
      document.write("Contents of the typed array after copy: "+int32View);
   </script>
</body>
</html>

আউটপুট

Contents of the typed array: 21,64,89,65,33,66,87,55
Contents of the typed array after copy: 21,64,89,65,33,21,64,89

উদাহরণ

এই ফাংশনে তৃতীয় প্যারামিটারটি পাস করা বাধ্যতামূলক নয় (অ্যারের শেষ উপাদান যা থেকে ডেটা কপি করা উচিত) এটি অ্যারের শেষ পর্যন্ত কপি করবে৷

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55 ]);
      document.write("Contents of the typed array: "+int32View);
      int32View.copyWithin(5, 0);
      document.write("<br>");
      document.write("Contents of the typed array after copy: "+int32View);
   </script>
</body>
</html>

আউটপুট

Contents of the typed array: 21,64,89,65,33,66,87,55
Contents of the typed array after copy: 21,64,89,65,33,21,64,89

  1. জাভাস্ক্রিপ্ট অ্যারে ফিল() ফাংশন

  2. JavaScript Array.of() ফাংশন

  3. JavaScript array.includes() ফাংশন

  4. JavaScript array.toLocaleString() ফাংশন