parseInt()
parseInt(string, radix)
파라미터로 숫자로 변환할 문자열과 수로 전환할 진법으로 하고 있다.
더하기 (+) 연산자
숫자로 변환할 문자열 앞에 + 연산자를 붙여주면 Number 타입으로 변환된다.
console.log(+"10"); // 10
console.log(+"10.1"); // 10.1
console.log(+"-10"); // -10
console.log(+"abc"); // NaN
console.log(+true); // 1
console.log(+false); // 0
곱하기 (*) 연산자
console.log("10" * 1); // 10
console.log("10.1" * 1); // 10.1
console.log("-10" * 1); // -10
console.log("abc" * 1); // NaN
문자열을 숫자로 변경할 수 없으면 NaN(Not a Number)를 리턴한다.
'기타 > WEB' 카테고리의 다른 글
[Next.js] Next.js 13 font 적용 (0) | 2023.06.10 |
---|---|
Node https 적용 (0) | 2022.08.28 |
MEDIA WIKI (0) | 2022.08.28 |
Cookies & Sessions (0) | 2022.08.28 |