Not quite grasping what's going on here. Given the array (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
}
]
And the object (obj):
{
"first_name": "Yoshi",
"last_name": "Woodson",
"id": 3
}
Why would arr.indexOf(obj)
return -1
(especially since I retrieved the object from the array using it's 'id' parameter earlier in the function)?
({a:12}) === ({a:12})
isfalse
. Objects in JavaScript are equal if they are the same object (same reference), not just the same values. – Hereditable