Computer >> Computer tutorials >  >> Programming >> Javascript

TypedArray.join() function in JavaScript


The join() function of the TypedArray object joins the contents of the typed array as single string and returns it. To this method you can pass a separator to separates the elements of the array.

Syntax

Its Syntax is as follows

typedArray.join(':')

Example

<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>

Output

:
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