본문 바로가기
2019/JavaScript

JS 숫자

by SOLYI 2019. 12. 6.

  • eval
  • parseInt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let a='10';
let b=10;
        
console.log(a+b);
//eval이벨 parseInt
console.log(eval('10')); 
console.log(parseInt('10'));
console.log(parseInt('abc'));  //NaN
        
console.log(isNaN('abc')); //true
console.log(isNaN('10'));  //false
console.log(isNaN(10));    //false
        
//NaN : not a Number
 

 

1
2
3
4
5
6
7
console.log(eval(10.2));     
//10.2 출력 (그대로 출력)
 
console.log(parseInt(10.2)); 
//10 출력  (정수로 변환하여 출력)
 
console.log(parseFloat(10.2));
반응형

'2019 > JavaScript' 카테고리의 다른 글

JS Array  (0) 2019.12.06
JS Date  (0) 2019.12.06
JS String  (0) 2019.12.06
JS Function  (0) 2019.12.06
JS for문  (0) 2019.12.05