천진난만 코딩 스토리

6. Function (2) 본문

노마드코더/JavaScript 기초

6. Function (2)

Wisdom_1104 2023. 1. 1. 20:10

- typeof -

string(문자)인지 number(숫자)인지 알려줌.

 

 

- parseInt -

string을 number로 변환, 변환이 안될 시 NaN

 

- prompt -

알림창에 질문창을 만듬.

 

 

예제 코드)

const age = prompt ("How old are you?");
console.log (typeof age);

15 => number

ori => string

 

 

const age = prompt ("How old are you?");
console.log (age, parseInt(age));

15 => 15   15

ori => ori    NaN

 

*NaN = Not a number

 

 

 

 

 

 

'노마드코더 > JavaScript 기초' 카테고리의 다른 글

8. 연산자 (+ if else)  (0) 2023.01.01
7. Function (3)+if, else  (0) 2023.01.01
5. Function (1)  (0) 2023.01.01
4. Object (객체)  (0) 2023.01.01
3. Array  (0) 2023.01.01