arr=[
{
maxDeptCode: "md3"
maxDeptName: "泡泡"
minDeptCode: "md301"
minDeptName: "泡泡少儿"
schoolId: 1
schoolName: "北京"
},
{
maxDeptCode: "md2"
maxDeptName: "中学"
minDeptCode: "md201"
minDeptName: "中学一对一"
schoolId: 1
schoolName: "北京"
},{
maxDeptCode: "md3"
maxDeptName: "泡泡"
minDeptCode: "md301"
minDeptName: "泡泡少儿"
schoolId: 1
schoolName: "北京"
},
]
当我选择的时候需要判断数组最大部门和最小部门两个都重复的对象,然后进行提示,已选择重复,同时去重,这种去重如何判断?请大神指点!
基本思路就是遍历并记录,每次遍历是检查记录是否已经出现过,
方法一,用
Array.prototype.find
方法二,用
Array.prototype.filter