String codePointAt() method

Find out all the information about the JavaScript codePointAt() method of the string

This feature was introduced in ES2015 to handle Unicode characters that cannot be represented by a single 16-bit Unicode unit but require 2 characters.

usecharCodeAt()You need to retrieve the first and second and merge them. usecodePointAt()You can get the whole character in one breath.

For example, this Chinese character "𠮷" is composed of 2 UTF-16 (Unicode):

"𠮷".charCodeAt(0).toString(16) //d842
"𠮷".charCodeAt(1).toString(16) //dfb7

If you create a new character by combining these unicode characters, do the following:

"\ud842\udfb7" //"𠮷"

You can get the same result as usigncodePointAt():

"𠮷".codePointAt(0) //20bb7

If you create a new character by combining these unicode characters, do the following:

"\u{20bb7}" //"𠮷"

More information about Unicode and its use in UnicodeUnicode and UTF-8.

Download mine for freeJavaScript beginner's manual


More js tutorials: