What is the difference between String.prototype.codePointAt()
and String.prototype.charCodeAt()
in JavaScript?
'A'.codePointAt(); // 65
'A'.charCodeAt(); // 65
What is the difference between String.prototype.codePointAt()
and String.prototype.charCodeAt()
in JavaScript?
'A'.codePointAt(); // 65
'A'.charCodeAt(); // 65
From Mozilla:
charCodeAt()
is UTF-16,codePointAt()
is Unicode.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt
from this url, you can get the differences, their function is almost the same, but some differences on the returns and illegal argument
To add a few for the ToxicTeacakes's answer, here is another example to help you know the difference: