JS Built-ins
TextEncoderbeginner

TextEncoder.encode β€” byte at index 1

πŸ“– Usage Example
const enc = new TextEncoder()
const buf = enc.encode('πŸŽ‰')
buf.length  // β†’ 4 (4 bytes for this emoji)

Emoji and other multi-byte characters produce multiple bytes per character.

encode() Second Byte

In encode('AB'), the second byte (index 1) is the ASCII code for 'B', which is 66.

Challenge: Verify encode('AB')[1] === 66.

πŸ’‘ Hints (1)
  • β€’ ASCII: A=65, B=66, C=67. Each character is one byte.