JavaScript parseInt()

1 개요[ | ]

JavaScript parseInt()
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('ff', 16));   // 255 (lower-case hexadecimal)
console.log(parseInt('0xFF', 16)); // 255 (upper-case hexadecimal with "0x" prefix)
console.log(parseInt('xyz'));      // NaN (input can't be converted to an integer)

2 같이 보기[ | ]

3 참고[ | ]

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