Skip to main content

· One min read
Leibniz Li

String.prototype.codePointAt

'☃★♲'.codePointAt(0);
// output: "9731"
'☃★♲'.codePointAt(1);
// output: "9733"
'☃★♲'.codePointAt(2);
// output: "9842"

"😀".codePointAt(0);
// output: "128512"
"😀".codePointAt(1);
// output: "56832"
"😀".codePointAt(0).toString(16);
// output: "1f600"
'😀'.length
// output: "2"

"🇺🇸".codePointAt(0);
// output: "127482"
"🇺🇸".codePointAt(1);
// output: "56826"
"🇺🇸".codePointAt(2);
// output: "127480"
"🇺🇸".codePointAt(3);
// output: "56824"
'🇺🇸'.length
// output: "4"