Number()와 parseInt() 차이 본문

2021 프론트 엔드 로드맵 따라가기/JS

Number()와 parseInt() 차이

알 수 없는 사용자 2021. 6. 4. 12:04

Number

Number("3만");	// NaN
Number("만 3세");	// NaN
Number(null);	// 0
Number(undefined);	// NaN
Number(" ");	// 0
Number();	// 0

 

parseInt

parseInt("3만");    // 3 (숫자로 시작할 경우에만 적용됨)
parseInt("만 3세");    // NaN
parseInt(null);	// NaN
parseInt(undefined);	// NaN
parseInt(" ");	// NaN
parseInt();	// NaN

'2021 프론트 엔드 로드맵 따라가기 > JS' 카테고리의 다른 글

Hoisting  (0) 2021.06.05
특정 범위의 랜덤 정수 값 생성 코드  (0) 2021.06.04
Local Storage & Session  (0) 2021.06.01
Event Bubbling & Delegation  (0) 2021.05.31
Key & Input events  (0) 2021.05.31
Comments