怎么判断这两个数组的object是否相等呢,需要的是不排序也能进行比较。
var list = [
{
"dept_name": "妇科门诊1", "q_type": 0, "room": "妇科一诊室",
"queue_time": "2021-04-18 09:31:03", "doctor": "莫春璘",
"patient_id": 66656, "patient_name": "张家荣", "id": 36999,
"dept_id": 99, "status": 7
},
{
"dept_name": "妇科门诊1", "q_type": 0,
"room": "妇科二诊室", "queue_time": "2021-04-18 09:31:03",
"doctor": "莫春璘", "patient_id": 66657, "patient_name": "杨淑君",
"id": 37000, "dept_id": 99, "status": 7
},
{
"dept_name": "妇科门诊1", "q_type": 0,
"room": "妇科三诊室", "queue_time": "2021-04-18 09:31:03",
"doctor": "莫春璘", "patient_id": 66658, "patient_name": "吴俊明",
"id": 37001, "dept_id": 99, "status": 7
},
]
var list2 = [
{
"dept_name": "妇科门诊1", "q_type": 0,
"room": "妇科二诊室","queue_time": "2021-04-18 09:31:03",
"doctor": "莫春璘","patient_id": 66656, "patient_name": "张家荣",
"id": 36999,"dept_id": 99, "status": 7
},
{
"dept_name": "妇科门诊1", "q_type": 0,
"room": "妇科二诊室", "queue_time": "2021-04-18 09:31:03",
"doctor": "莫春璘", "patient_id": 66657, "patient_name": "杨淑君",
"id": 37000, "dept_id": 99, "status": 7
},
]
向大神求教!!
可能我描述的不是很清楚,想要的结果不是两个数组是否相等,是数组内的object是否有相等的,如果object相等的话,就把不相等的重新构建一个新数组
题目修改后的最新回答:
利用deep比较,加个去重就行
以下为题目修改前的回答:
用法:
另外,有两个很好用的深度比较模块
deep-equal
,fast-deep-equal
;npm install deep-equal
前端使用deep-equal 例子, 基于umi和ts