好吧,这真的让我疯了。我不知道为什么我一直在uncaught typeError: cannot read property '0' of undefined
有人可以指出导致uncaught error
此阵列线上的原因吗num = myArray[0];
var val= this.value;
myArray = checkinput(val);
num = myArray[0];
data = myArray[1];
if (num == 0 ) {
....
} else {
....
}
/*FUNCTIONS*/
function checkinput(val) {
var val;
//some regex here
if (regexA.test(val)) {
var fname = val.match(regexA)[0];
var arr = [0,fname]; // 0 as identifier
return arr;
}
else if (regexB.test(val)) {
var lname = val.match(regexB)[0];
var arr= [1,lname]; // 1 as identifier
return arr;
}
}