JavaScript TypedArray.prototype.join()で配列の要素を文字列に結合する

環境
Google Chrome  115.0.5790.171(Official Build) (64 ビット)
Windows 11 Pro 64bit

構文
join()
join(separator)
sepratator 配列の各要素を区切る文字列を指定します。
戻り値
join() メソッドは、配列のすべての要素を 1 本の文字列に結合します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const uint8 = new Uint8Array([11, 22, 33]);
console.log(uint8.join());
console.log(uint8.join('*'));
console.log(uint8.join('/'));
const uint8 = new Uint8Array([11, 22, 33]); console.log(uint8.join()); console.log(uint8.join('*')); console.log(uint8.join('/'));
 const uint8 = new Uint8Array([11, 22, 33]);

console.log(uint8.join());

console.log(uint8.join('*'));

console.log(uint8.join('/'));

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
> "11,22,33"
> "11*22*33"
> "11/22/33"
> "11,22,33" > "11*22*33" > "11/22/33"
> "11,22,33"
> "11*22*33"
> "11/22/33"

 

JavaScript

Posted by arkgame