JavaScript TypedArray join() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
ES2015

Definition

typedArray.join(separator) joins all the elements into one string. Between two elements it puts the separator; the default is a comma. The elements are written as numbers, so new Uint8Array([1, 2, 3]).join() is "1,2,3". An empty typed array gives an empty string. It is the best way to print a typed array in a clear and portable way, because every engine gives the same text.

Remember
typedArray.join()        → "1,2,3"   (default comma)
typedArray.join(" - ")   → "1 - 2 - 3"
typedArray.join("")      → "123"

new Uint8Array(0).join("x")   → ""
new Float32Array([0.5, 0.1]).join()
                              → "0.5,0.10000000149011612"

Syntax

The separator is optional. Without it, a comma is used.

JavaScript
typedArray.join()
typedArray.join(separator)
CallWhat it does
ta.join()Join with commas: "1,2,3".
ta.join(" - ")Join with any text you choose between the elements.
ta.join("")Glue the numbers together with nothing in between.

Built into JavaScript since ES2015 on all 11 typed array types. BigInt arrays work too: new BigInt64Array([1n, 2n]).join("+") is "1+2".

Library declarations
JavaScript
TypedArray.prototype.join(separator)   // returns a string

// separator: undefined -> ","  (anything else is turned into a string)
// elements are written like String(element)
// an empty typed array returns ""

Parameters

ParameterDescription
separator (optional)The text put between two elements. If it is missing or undefined, a comma is used. Other values are converted to a string, so null gives the text "null", and 0 gives "0".

Return Value

Return ValueDescription
StringOne string with the elements in order, separated by the separator. An empty array gives "". It is the same idea as Array join().

JavaScript Examples

Example 1 — Choose the Separator

Three bytes are joined in different ways. The last line shows that an empty typed array gives an empty string.

JavaScript
const bytes = new Uint8Array([1, 2, 3]);

console.log(bytes.join());          // 1,2,3
console.log(bytes.join(' - '));     // 1 - 2 - 3
console.log(bytes.join(''));        // 123

const none = new Uint8Array(0);
console.log('[' + none.join('x') + ']');   // []
Try It Yourself

How It Works

  1. No argument means a comma. Without a separator, join() writes 1,2,3, with no spaces.
  2. Any text works as glue. The separator can be several characters long, such as " - ", or empty, which gives 123.
  3. Empty in, empty out. With zero elements there is nothing to join, so the result is an empty string. The square brackets make that visible.

Example 2 — Build a CSS Colour From Bytes

A colour is three bytes: red, green, blue. join() turns them into the text that CSS understands.

JavaScript
const orange = new Uint8Array([255, 128, 0]);

console.log('rgb(' + orange.join(', ') + ')');   // rgb(255, 128, 0)

const hex = Array.from(orange, (n) => n.toString(16).padStart(2, '0'));
console.log('#' + hex.join(''));                 // #ff8000
console.log(typeof orange.join());               // string
Try It Yourself

How It Works

  1. Comma and space between channels. orange.join(", ") gives 255, 128, 0, which fits right inside rgb( ).
  2. Hex needs two digits per byte. Array.from turns each byte into two hex letters. The value 0 becomes 00 thanks to padStart.
  3. The result is a string. typeof reports string, so you can add it to other text or send it as it is.

Example 3 — How Floats and BigInts Are Written

Elements are written the way String(number) writes them. That shows the stored value, including single-precision rounding.

JavaScript
const f = new Float32Array([0.5, 0.1, -0]);
console.log(f.join());                           // 0.5,0.10000000149011612,0

const odd = new Float32Array([NaN, Infinity]);
console.log(odd.join('/'));                      // NaN/Infinity

const big = new BigInt64Array([1n, 2n]);
console.log(big.join('+'));                      // 1+2
console.log(new Uint8Array([1, 2, 3]).join(null));   // 1null2null3
Try It Yourself

How It Works

  1. The stored value is shown. A Float32Array cannot hold 0.1 exactly, so join() prints the nearest single-precision number. Minus zero prints as plain 0.
  2. Special numbers have names. NaN and Infinity are written as those words, with the slash separator between them.
  3. Separators become text. BigInts print without the n, and null as a separator is turned into the four letters "null".

Browser & Runtime Support

TypedArray.prototype.join() is part of ES2015 (ES6), together with typed arrays and the other array-like methods.

✓ Baseline · ES2015

TypedArray.prototype.join()

Supported in every modern browser, plus Node.js, Deno, and Bun.

98% Modern browser support
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Node.js All current releases
Supported
Deno All releases
Supported
Internet Explorer IE 10 and 11 have typed arrays, but not this method
Not supported
join() Excellent

Bottom line: Safe everywhere modern JavaScript runs. Internet Explorer 10 and 11 have typed arrays but not this method, so join a plain Array there.

Frequently Asked Questions

One string with all the elements written as numbers and the separator between them. An empty typed array gives an empty string.
A comma, written without a space. For example, new Uint8Array([1, 2, 3]).join() gives "1,2,3". Pass " " or ", " when you want spaces.
console.log(ta) prints a different format in Node.js and in browsers. ta.join(" ") gives the same plain text everywhere, so examples and output always match.
No. It only reads the elements and returns a new string. The typed array keeps its values and its length.
Split it and convert: Uint8Array.from("1,2,3".split(","), Number). Typed arrays do not have a method that parses text directly.

Next: keys()

Get an iterator over the indexes of the typed array.

keys() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful