Skip to main content

TextEncoder (class)

The built-in TextEncoder object allows one to read the value into an actual an arrat od octets, given the target string.

Status: unstable

Constructor Parameters

Example usage

const encoder = new TextEncoder();

Extra behaviors

Instance Methods

TextEncoder.encode(string)

Status: unstable
Returns: number[]

Parameters

NameTypeDescription
stringstringThe string to be encoded into a number[]

Example usage

const encoder = new TextEncoder();
const octets = encoder.encode("Hello World");

Extra behaviors