var arr = [
{
groups: {
TypeID: 'AV601'
}
}
]
var prop = {
TypeID: 'AV601'
}
console.log(arr[0].groups);
console.log(prop);
console.log(arr[0].groups === prop)// false
How can this give false? They are the same?
var arr = [
{
groups: {
TypeID: 'AV601'
}
}
]
var prop = {
TypeID: 'AV601'
}
console.log(arr[0].groups);
console.log(prop);
console.log(arr[0].groups === prop)// false
How can this give false? They are the same?
It's because Javascript compares objects by reference, not by keys equality. Those two objects simply have the same key name with the equal key value, but in memory, they point to different address.
let o1= {}; // points to address "#aaa" in memory
let o2= {}; // points to address "#bbb" in memory
o1 === o2; // false