array的方法 没记住的

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());
原文地址:https://www.cnblogs.com/shuaishuaidejun/p/8144327.html