Asc value

Ascii value with JS


a-z = 97-122
A-Z = 65-90

Get Ascii value from string

"string".charCodeAt(string index) 

"HELLO".charCodeAt(0);  // gives asccii for H : 72
"HELLO".charCodeAt(1); // gives asccii for E : 69
"HELLO".charCodeAt(2); // gives asccii for L : 76
"HELLO".charCodeAt(3); // gives asccii for L : 76
"HELLO".charCodeAt(4); // gives asccii for O : 79
"HELLO".charCodeAt(5); // gives asccii for \n : NaN


Get character from ascii value


String.fromCharCode(ascii value);  

String.fromCharCode(72); // return H



charAt()


str.charAt(index)

It is simiral to access string with index

str[index]


8 bit Binary into char 

 binval = "01000001";

intval = parseInt(  binval , 2 ); // cast to integer for given value, 2nd param is base 
// intval = 65;
// ascii for 65 is A;

   


Share this

Related Posts

Previous
Next Post »