可能重复:
How to parseInt a string with leading 0的javascript parseInt函数
如果我parseInt函数( “01”)在JavaScript其不一样parseInt函数( “1”)???
start = getStartEugene("MN01");
start2 = getStartEugene("MN1");
getStartEugene: function(spot) //ex: GT01 GT1
{
var yard = spot.match(/[0-9]+/);
var yardCheck = parseInt(yard);
if (yardCheck < 10)
return "this"+yard;
else
return "this0"+yard
}
我想要的东西被退回,因为这+ 2位数,如this25,this55,this01,this02,this09
,但我没有得到它。有人知道为什么
在代码中甚至不需要'parseInt'。 –
你不明白这个问题。我需要知道它的单个数字是不是因为输入可能是MT01或MT1 @FelixKling – ealeon
啊对,我错过了“MN1”例子...... –