Prefer String#codePointAt(…)
over String#charCodeAt(…)
and String.fromCodePoint(…)
over String.fromCharCode(…)
💼 This rule is enabled in the ✅ recommended
config.
💡 This rule is manually fixable by editor suggestions.
Unicode is better supported in String#codePointAt()
and String.fromCodePoint()
.
const unicorn = '🦄'.charCodeAt(0).toString(16);
const unicorn = String.fromCharCode(0x1f984);
const unicorn = '🦄'.codePointAt(0).toString(16);
const unicorn = String.fromCodePoint(0x1f984);