JavaScript로 크롬 앱 만들기 #6

Heeseung Ha·2021년 11월 22일

노마드 코더 - 바닐라 JS로 크롬 앱 만들기 #6

✔ typeof

  • 자료형을 알고 싶을 때 사용한다.
  • typeof (variable) 로 나타낸다.
const age = prompt("How old are you?");
console.log(typeof age);
string

✔ prompt()

  • 창을 띄워서 값을 입력받게 한다.

✔ string을 number로

  • parseInt: string 형태의 변수를 number 형태로 변환해준다.
const age = prompt("How old are you?");
console.log(typeof age, typeof parseInt(age));
string number

입력값이 string에서 number로 형변환 되었음을 알 수 있다.

profile
FE 개발 공부중...💫

0개의 댓글