JavaScript 문자열을 int로 변환

1 개요[ | ]

JavaScript 문자열을 int로 변환
console.log(Number('123')); // 123
console.log(parseInt('123'));     // 123 (default base-10)
console.log(parseInt('123', 10)); // 123 (explicitly specify base-10)
console.log(parseInt('   123 ')); // 123 (whitespace is ignored)
console.log(parseInt('077'));     // 77 (leading zeros are ignored)
console.log(parseInt('1.9'));     // 1 (decimal part is truncated)
console.log(parseInt('xyz'));     // NaN (input can't be converted to an integer)

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}