JavaScript parseInt() Function: Parsing Strings to Integers
The parseInt function in JavaScript parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems). If the radix is not specified, it assumes 10. If the first character of the string cannot be converted to a number, it returns NaN (Not a Number). For example:
parseInt('10'); // returns 10 parseInt('010'); // returns 10 (octal notation) parseInt('10', 2); // returns 2 (binary notation) parseInt('hello', 10); // returns NaN
原文地址: https://www.cveoy.top/t/topic/nTCX 著作权归作者所有。请勿转载和采集!