What is equivalent php chr() and ord() functions in javascript What is equivalent php chr() and ord() functions in javascript javascript javascript

What is equivalent php chr() and ord() functions in javascript


var res = String.fromCharCode(65);

This function will worked well same as chr() function returns character in javascript.


function myFunction() {var str = "HELLO WORLD";var n = str.charCodeAt(0);    document.getElementById("demo").innerHTML = n;}

and for ord() you can use the above function for JavaScript


this code is the javascript equivalent to the PHP ord() function.

function ord(str){return str.charCodeAt(0);}