JS Built-ins
TextDecoderbeginner

TextDecoder β€” default encoding

πŸ“– Usage Example
const dec = new TextDecoder()
dec.decode(new Uint8Array([72,105]))  // β†’ 'Hi'

TextDecoder converts a Uint8Array of bytes into a JavaScript string.

TextDecoder Constructor

new TextDecoder() defaults to UTF-8. The encoding property returns 'utf-8'.

Challenge: Access the encoding property of a default TextDecoder.

πŸ’‘ Hints (1)
  • β€’ TextDecoder defaults to UTF-8 when no label is provided.