TextEncoder.prototype.encode

Encodes a string into a Uint8Array containing UTF-8 bytes.

Syntax

encode(string)

Parameters

Example

new TextEncoder().encode("hello")
Uint8Array [104, 101, 108, 108, 111]

See also