不太明白这里发生了什么。给定数组 (arr):
[
{
"first_name": "Dan",
"last_name": "Woodson",
"id": 1
},
{
"first_name": "Jen",
"last_name": "Woodson",
"id": 2
},
{
"first_name": "Yoshi",
"last_name": "Woodson",
"id": 3
}
]
和对象(obj):
{
"first_name": "Yoshi",
"last_name": "Woodson",
"id": 3
}
为什么会arr.indexOf(obj)
返回-1
(特别是因为我在函数的前面使用它的 'id' 参数从数组中检索了对象)?