Computer >> Máy Tính >  >> Lập trình >> Javascript

Hàm TypedArray.join () trong JavaScript

Hàm join () của đối tượng TypedArray kết hợp nội dung của mảng đã nhập dưới dạng chuỗi đơn và trả về nó. Đối với phương pháp này, bạn có thể chuyển một dấu phân tách để phân tách các phần tử của mảng.

Cú pháp

Cú pháp của nó như sau

typedArray.join(':')

Ví dụ

<html>
<head>
   <title>JavaScript Array every Method</title>
</head>
<body>
   <script type="text/javascript">
      var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);
      document.write("<br>");
      var contains = int32View.join('');
      document.write("."+contains);
      document.write("<br>");
      document.write(int32View.join(':'));
      document.write("<br>");
      document.write(int32View.join('-'));
      document.write("<br>");
      document.write(int32View.join(' '));
   </script>
</body>
</html>

Đầu ra

:
2119652114668755
21:19:65:21:14:66:87:55
21-19-65-21-14-66-87-55
21 19 65 21 14 66 87 55