How to use charCodeAt() method to get an integer between 0 and 65535 (UTF-16) from a given string index in JavaScript

1 Answer

0 votes
var s = 'Online Cloud Products';

document.write(s.charCodeAt(0) + "<br />");
document.write(s.charCodeAt(1) + "<br />");
document.write(s.charCodeAt(2) + "<br />");
document.write(s.charCodeAt(3) + "<br />");
document.write('ABCD'.charCodeAt(0) + "<br />");
document.write(s.charCodeAt(100) + "<br />");

/*
run:

79
110
108
105
65
NaN

*/

 



answered Aug 9, 2016 by avibootz
...