我有一个推送数组的功能,但我遇到了问题,因为我的条件总是一起检查。除此之外,如果我使用花括号,我将创建数组编号。次。即使我无法在这里正确解释,请查看我的代码:
$.map(pObj,function(values,i){
if(typeof pieArray[values.GeoID] == 'undefined')
pieArray[values.GeoID] = []; //it should create only one time
pieArray[values.GeoID].push(values.ResponsePercentage); // when it matches it should not go down to check next if. else it can go.
if(!values.GeoID && typeof pieArray[0] == 'undefined')
pieArray[0] = []; //it should create only one time
pieArray[0].push(values.ResponsePercentage); //now the top if get response, till it is checking and throwing error. top if not match, then it need to work.
});
我怎样才能做到这一点?