Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.24 KB

prefer-code-point.md

File metadata and controls

32 lines (22 loc) · 1.24 KB

Prefer String#codePointAt(…) over String#charCodeAt(…) and String.fromCodePoint(…) over String.fromCharCode(…)

This rule is part of the recommended config.

💡 This rule provides suggestions.

Unicode is better supported in String#codePointAt() and String.fromCodePoint().

Fail

const unicorn = '🦄'.charCodeAt(0).toString(16);
const unicorn = String.fromCharCode(0x1f984);

Pass

const unicorn = '🦄'.codePointAt(0).toString(16);
const unicorn = String.fromCodePoint(0x1f984);