12 2021 档案

摘要:1.判断数组是否为空 const isEmptyArr=(arr)=>arr.length==0&&console.log('空数组') 2.判断对象是否为空 const isEmptyObj=(obj)=>Object.keys(obj).length==0&&console.log('空对象') 阅读全文
posted @ 2021-12-27 15:03 红豆丁 阅读(59) 评论(0) 推荐(0)
摘要: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',' 阅读全文
posted @ 2021-12-24 14:47 红豆丁 阅读(48) 评论(0) 推荐(0)
摘要:1、数组对象去重 (1)根据某属性去重 let data = [ { name: 'ws', id: 1 }, { name: 'cj', id: 2 }, { name: 'jf', id: 3 }, { name: 'll', id: 1 }, { name: 'wwx', id: 2 }, { 阅读全文
posted @ 2021-12-24 14:18 红豆丁 阅读(44) 评论(0) 推荐(0)