function setmonth(mListBox, mSelected) {
var monthList = new Array( "01 ", "02 ", "03 ", "04 ", "05 ", "06 ", "07 ", "08 ", "09 ", "10 ", "11 ", "12 ");
for (var i = 0; i <= monthList.length-1; i++) {
alert( "i== "+monthList[i]);
alert( "parseInt= "+parseInt(monthList[i]));
}
}
就像上面的代码一样,最后将08,09 变成整型之后就是0,这是为什么呢?
很着急,请大家帮帮忙
------解决方案--------------------
alert(parseInt( "08 ",10));
alert(parseInt( "09 ",10));
------解决方案--------------------
当在前面有 "0 "时,javascript的debugger会认为是一个八进制数,而 "08 "和 "09 "不是一个合法的八进制数,所以导致了那个问题
zhaoxiaoyang(梅雪香@深圳)指明是十进制则是对的
------解决方案--------------------
以0开头的数值类型为八进制数.