Skip to content

Latest commit

Β 

History

History
32 lines (21 loc) Β· 1.3 KB

File metadata and controls

32 lines (21 loc) Β· 1.3 KB

prefer-code-point

πŸ“ Prefer String#codePointAt(…) over String#charCodeAt(…) and String.fromCodePoint(…) over String.fromCharCode(…).

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ’‘ This rule is manually fixable by editor suggestions.

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

Examples

// ❌
const unicorn = 'πŸ¦„'.charCodeAt(0).toString(16);

// βœ…
const unicorn = 'πŸ¦„'.codePointAt(0).toString(16);
// ❌
const unicorn = String.fromCharCode(0x1f984);

// βœ…
const unicorn = String.fromCodePoint(0x1f984);