let list = [{
name:'小明',
tel:'13088888888'
},{
name:'小李',
tel:'13088888899'
},{
name:'小金',
tel:'13088888877'
},{
name:'小明',
tel:'13088888888'
},{
name:'小天',
tel:'13088888855'
}]
先做排序
//中文排序
function sortChinese(arr, dataLeven) {
function getValue (option) {
if (!dataLeven) return option
var data = option
dataLeven.split('.').filter(function (item) {
data = data[item]
})
return data + ''
}
arr.sort(function (item1, item2) {
return getValue(item1).localeCompare(getValue(item2), 'zh-CN');
})
}
sortChinese(list, 'name')
获取重复数据
let _res = [];
for(let i = 0; i < list.length;) {
let count = 0;
for(let j = i; j < list.length; j++) {
if(list[i].name == list[j].name) {
count++;
}
}
let obj = {
name:list[i].name,
num:count
}
_res.push(obj)
i += count;
}
console.log('_res',_res)
上面是“js找出数组中重复的元素和重复次数”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2118.html
workflows工作流
在月球上穿着太空服的宇航员
一匹热血沸腾的汗血宝马庄严地站立着ComfyUI工作流
《翅膀之王:鸡的团契》海报ComfyUI工作流
一个神秘的隐藏面孔下一本书的剪影ComfyUI工作流
一个超凡脱俗的女明星的特写镜头ComfyUI工作流
一把令人难忘的美丽吉他ComfyUI工作流
树上挂着一只表情可爱的香蕉ComfyUI工作流二
森林里一只空灵的犀鸟ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

html5如何3D立方体旋转特效
js导出excel插件(兼容mac电脑Numbers表格)
利用canvas画几个好玩的星云物种
纯CSS饼图效果
利用js做一个炫酷音乐背景效果
数字滚动效果(兼容IE6/IE8)
利用html5+css3实现滚雪球效果(附代码)
利用css3做一个动态loading效果









