JS Built-ins
TextEncoderbeginner

TextEncoder β€” encode empty string

πŸ“– Usage Example
const enc = new TextEncoder()
enc.encode('A')  // β†’ Uint8Array [65]

encode() converts a string into a Uint8Array of UTF-8 bytes.

Encoding an Empty String

new TextEncoder().encode('') returns a Uint8Array with length === 0.

Challenge: Verify that encoding an empty string gives a zero-length Uint8Array.

πŸ’‘ Hints (1)
  • β€’ Encoding an empty string produces an empty byte array.