728x90
✨ 원하는 알파벳이나 숫자(0-9)의 아스키 코드(ASCII Code)를 알고 싶을 때, 사용하는 helper method
(e.g., str.charCodeAt(0)) 왼쪽처럼 알고 싶은 string의 index를 넣어서 사용한다. ()안에 아무것도 넣지 않으면 default 0
백준 11654번: 아스키 코드, 10809번: 알파벳 찾기 문제를 풀 때 사용하였다.
💻Example Code
const str = 'a';
const numStr = '1';
console.log( str.charCodeAt(0) );
console.log( numStr.charCodeAt(0) );
console.log( 'a'.charCodeAt(0) );
😋 JavaScript에서 string의 ASCII Code를 알고 싶을 때 사용하면 된다.
👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
'JavaScript > Built-in Method etc.' 카테고리의 다른 글
Array.prototype.indexOf() (0) | 2020.01.01 |
---|---|
String.prototype.match() (0) | 2019.12.31 |
new String() (0) | 2019.12.29 |
new Array() (0) | 2019.12.29 |
Array.prototype.메소드() 만들기 (0) | 2019.12.29 |