Javascript – Convert character to ASCII code in JavaScript

javascript

How can I convert a character to its ASCII code using JavaScript?

For example:

get 10 from "\n".

Best Solution

"\n".charCodeAt(0);