Syntax
str.codePointAt(pos)
Parameters
pos:Position of an element in the String to return the code point value from.
Return value
A number representing the code unit value of the character at the given index; undefined if there is no element at pos.
Browser compatibility
使用方法:
function is32Bit(c) {
let s = c.codePointAt(0) > 0xFFFF ? true : false;
console.log(s);
return c.codePointAt(0) > 0xFFFF;
}
// ��
is32Bit(‘��’); // true
is32Bit(‘a’); // false