JS Built-ins
StringString.fromCodePointintermediate

String.fromCodePoint() vs fromCharCode β€” BMP equivalence

πŸ“– Usage Example
String.fromCodePoint(65)       // β†’ 'A'
String.fromCodePoint(9731)     // β†’ 'β˜ƒ'
String.fromCodePoint(128512)   // β†’ 'πŸ˜€'

Use String.fromCodePoint() to create a string from Unicode code point values, including characters outside the BMP.

fromCodePoint vs fromCharCode

For code points in the Basic Multilingual Plane (0–65535), String.fromCodePoint and String.fromCharCode produce the same result.

Challenge: Implement sameResult(code) that returns true when String.fromCodePoint(code) equals String.fromCharCode(code).

sameResult(65)  // β†’ true
πŸ’‘ Hints (1)
  • β€’ For code points ≀ 65535 both methods agree; above that they diverge.