Take this code:
var charCode = unkownVariable.charCodeAt(0);
What is the max length that charCode
can be? All my tests turned out as 2 character (2 digits). Will it ever be longer?
From the specification:
Returns a Number (a nonnegative integer less than 216) representing the code unit value of the character at position
pos
in the String resulting from converting this object to a String. If there is no character at that position, the result isNaN
.
So, 216 - 1 is the maximum value, which is 65535
.