console.log(ages); //=> [17,35]
= 10;
}
var filtered = [12,5,8,130,44].filter(isBigEnough);
// filtered is [12,44]
// usage example:
var a = ['a',1,'a',2,'1'];
var unique = a.filter( onlyUnique ); // returns ['a','1']
// usage example:
var a = ['a',1,'a',2,'1'];
var unique = a.filter( onlyUnique ); // returns ['a','1']
比较好使的Function(不兼容IE7)
比较好使的Function(兼容IE7)
var arr = ["北京","上海","天津","武汉","北京","武汉"];
arr = getNoRepeat(arr);
alert(arr.length);// 4
alert(arr.toString()); // "北京","武汉"
利用map原理
arr = new Array();
for(var key in json){
arr.push(key);
}
alert(arr.toString());
// "北京","武汉"