const string = "🦊"; // U+1F98A
console.log(string.length); // 2UTF-16 / notebook
UTF-16
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const string = "🦊"; // U+1F98A
console.log(string.charCodeAt(0).toString(16)); // d83e
console.log(string.charCodeAt(1).toString(16)); // dd8a
console.log(string.codePointAt(0).toString(16)); // 1f98a