<script>
var b = parseint ("a");
Alert ("b=" +b); 1
var c = parseint ("09/08/2009");
Alert ("c=" +c); 0
</script>
The answer is b=1,c=0.
parseint () is used to parse the string, and the return value is an integer. There are several features:
1, ignoring the first and last spaces of the parsed string, that is: "111" and "111" are the same
2), formal format is parseint (String,radix). Radix can be omitted, as an integer between 0 or 2-36, to denote the binary of the parsed value. (Note that it is not a system that resolves the returned results.) If Radix is not within this range, return Nan.
3), if the radix is omitted or 0, the string is parsed by the default system. The first character of string is 0, the default resolution is 8. The string with the first character of 0x is resolved to 16 by default. In other cases, the default is 10. 4, parsing from the first can be resolved from the beginning of the character, to the first unresolved characters (such as spaces, punctuation, etc.) end. The characters that follow are no longer parsed. Returns Nan if the first character cannot be resolved. such as "a8989"
Now we can look back at this problem is easy to understand:
The first letter of B is 0, and the following value is parsed by 8, which is 1 of 8. The natural return value is 1.
The difficulty lies in the second one.
The first character of C is 0, and the general idea is to parse it by 8. But we found that the second character, 9, is not a 8-digit number, which means that 9 is the first character that cannot be resolved. parseint ("09/08/2009") became a parseint ("0"), and the result was more pronounced, 0.
If we slightly change the parseint ("0119/08/2009"), the first character is 0, the octal parsing, the same reading to 9 can not parse. It becomes parseint ("011"), and the result is obviously 9.