12 2021 档案
摘要:1.判断数组是否为空 const isEmptyArr=(arr)=>arr.length==0&&console.log('空数组') 2.判断对象是否为空 const isEmptyObj=(obj)=>Object.keys(obj).length==0&&console.log('空对象')
阅读全文
摘要:1.字符串统计出现次数 let str="helloword?no.thank" const obj={} for(let item of str){ obj[item]=obj[item]+1 || 1 } console.log(obj) 2.数组统计出现次数 let arr = ['vs','
阅读全文
摘要:1、数组对象去重 (1)根据某属性去重 let data = [ { name: 'ws', id: 1 }, { name: 'cj', id: 2 }, { name: 'jf', id: 3 }, { name: 'll', id: 1 }, { name: 'wwx', id: 2 }, {
阅读全文