String.fromCodePoint(...[127482, 127480])
gives me a flag of the US ().
How do I turn the flag back to [127482, 127480]
?
String.fromCodePoint(...[127482, 127480])
gives me a flag of the US ().
How do I turn the flag back to [127482, 127480]
?
Copyright © 2021 Jogjafile Inc.
You're looking for
codePointAt
, perhaps using spread (etc.) to convert back to array and then mapping each of them.or
or skipping an interim step as Sebastian Simon pointed out via
Array.from
and its mapping callback:Example:
Spread and
Array.from
both work by using the strings iterator, which works by code points, not code units like most string methods do.