InterviewHubPRO
Section Overview
Q340

Question 340 of 521

Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

65%
JavaScript Internals (521 Qs)•Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

How do you convert character to ASCII code

You can use the String.prototype.charCodeAt() method to convert string characters to ASCII numbers. For example, let's find ASCII code for the first letter of 'ABC' string,

javascript
  "ABC".charCodeAt(0); // returns 65

Whereas String.fromCharCode() method converts numbers to equal ASCII characters.

javascript
  String.fromCharCode(65, 66, 67); // returns 'ABC'