最佳答案
我的原则
var arr = ['a','b',1];
var results = arr.map(function(item){
if(typeof item ==='string'){return item;}
});
这给出了以下结果
["a","b",undefined]
我不希望 undefined出现在结果数组中。我该怎么做呢?