JavaScript

[Javascript] 아스키코드 활용하기 / '문자'.codePointAt(), String.fromCodePoint('숫자')

hellosonic 2023. 8. 2. 21:23

'문자'.codePointAt() : 문자를 아스키코드로 변환

var str = "S";
var ascii = str.codePointAt();

console.log(ascii); // 83

String.fromCodePoint('숫자') : 아스키코드를 문자로 변환

var ascii = 83;
var str = String.fromCodePoint(ascii);

console.log(str); // S

암기법 : fromCodePointAt