JS는
C언어처럼 숫자에 short, int, long,,,,등등 구별할 필요 없이
모든 숫자는 number로 통일
//number
const count = 17;
const size = 17.1;
console.log(`value: ${count}, type: ${typeof count}`);
console.log(`value: ${size}, type: ${typeof size} `);
그 외 알아둬야할 숫자와 관련된 종류
infinity : + 로 무한
-infinity : - 로 무한
NaN : 숫자가 아니다
//special numberic values : infinity,-infinity,NaN
//숫자인지 확인잘하기
//특별한 넘버 종류로 받아서 무한대가 되어 사용자에게 에러 발생
//그래서 그 값이 유효한 값인지 확인하고 사용하는게 중요
const infinity = 1/0
const negativeInfinity = -1/0;
const nAn = 'not a number'/2;
console.log(infinity);
console.log(negativeInfinity);
console.log(nAn);
//bigInt
const bigInt =123456789n;
console.log(`vlaue: ${bigInt}, type: ${typeof bigInt}`);'끄적끄적' 카테고리의 다른 글
| Git 왜 써야함? (0) | 2022.07.29 |
|---|---|
| JS) symbol : 동일한 string으로 심볼 만들고 싶을때와 그렇지 않을때 (0) | 2022.07.29 |
| JS) Var hoisting이란? (0) | 2022.07.28 |
| JS) 순수 자바스크립트를 쓸 때는 코드 맨 위에 'use strict'; 를 써주자 (0) | 2022.07.28 |
| JS) Script async 이랑 defer 차이 (0) | 2022.07.28 |
댓글