reserve() 是倒叙;
sort() 拍序,按字符编码排序,可以传一个参数
reduce() 实例:判断一个数组里参数的个数
var
arr = [
"apple"
,
"orange"
,
"apple"
,
"orange"
,
"pear"
,
"orange"
];
function
getWordCnt(){
return
arr.reduce(
function
(prev,next){
prev[next] = (prev[next] + 1) || 1;
return
prev;
},{});
}
console.log(getWordCnt());