I\'ve been playing around with JS and can\'t figure out how JS decides which elements to add to the created array when using Array.from(). For example, the followin
It's all about the code behind the characters. Some are coded in two bytes (UTF-16) and are interpreted by Array.from as two characters. Gotta check the list of the characters :
http://www.fileformat.info/info/charset/UTF-8/list.htm
http://www.fileformat.info/info/charset/UTF-16/list.htm
function displayHexUnicode(s) {
console.log(s.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(4,"0"),""));
}
displayHexUnicode('षि');
console.log(Array.from('षि').forEach(x => displayHexUnicode(x)));
function displayHexUnicode(s) {
console.log(s.split("").reduce((hex,c)=>hex+=c.charCodeAt(0).toString(16).padStart(4,"0"),""));
}
displayHexUnicode('