摘要: //浅拷贝 function shallowCopy(src){ if(typeof src != 'object'){ return src; } var dest = Array.isArray(src) ? [] : {}; for(var p in src){ if(src.hasOwnProperty(p)){ ... 阅读全文
posted @ 2017-12-30 22:17 全玉 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 数组扁平化 //ES5写法 function flatten(arr){ return arr.reduce(funcion(pre,cur,index){ return pre.concat(Array.isArray(cur) ? flatten(cur) : cur); },[]); } // 阅读全文
posted @ 2017-12-30 18:51 全玉 阅读(95) 评论(0) 推荐(0) 编辑