Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

charcodeat vs codepointat

/* String.charCodeAt(index) vs String.codePointAt(index) */

// Both methods return an integer representing the UTF-16 code.
'ABC'.charCodeAt(2); // → 67
'ABC'.codePointAt(2); // → 67

/* However, charCodeAt doesn't provide a full character code for 
values greater than 0xFFFF, only the first part of a surrogate pair.
This is common for emoji. */
"{horse emoji}".charCodeAt(0); // → 55357
"{horse emoji}".codePointAt(0); // → 128052

/* (Displaying emoji not currently supported
by Grepper, so use your imagination above.) */
Comment

PREVIOUS NEXT
Code Example
Javascript :: concurrently script 
Javascript :: de structuring value from object ES6 and javascript 
Javascript :: javascript object total 
Javascript :: js format urcurency 
Javascript :: js check if number has decimals 
Javascript :: canada postal code regex 
Javascript :: javascript redirect page 
Javascript :: javascript redirect to 
Javascript :: javascript redirect to a page 
Javascript :: pick random value from array 
Javascript :: js object contain key 
Javascript :: how to use await to console 
Javascript :: cypress set viewport for all test cases 
Javascript :: mute video javascript 
Javascript :: javascript for loops in vs of 
Javascript :: redirecting to a different route if user is logged in 
Javascript :: set bg image in react 
Javascript :: react media query hook 
Javascript :: onclick event in angular 
Javascript :: jquery observe class change 
Javascript :: importing svg into react 
Javascript :: javascript compare two objects 
Javascript :: finding in mongoose using a name 
Javascript :: angular one array contains any of second 
Javascript :: verify if number is not floating 
Javascript :: how to get clicked element class in jquery 
Javascript :: javascript swap two variables 
Javascript :: sequelize limit 
Javascript :: javascript remove html element 
Javascript :: ng new module w route 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =