123-Essential-JavaScript-Interview-Questions icon indicating copy to clipboard operation
123-Essential-JavaScript-Interview-Questions copied to clipboard

Question 31

Open Enzaik opened this issue 4 years ago • 3 comments

Both compares return false. This is because in JavaScript we pass non primitive data types by reference. So, say: {id:1} == {id:1} // returns false even though is shallow compare, we are not comparing here two objects values, but 2 references, which are different.

Enzaik avatar Sep 09 '19 09:09 Enzaik

you are totally right, this question is misleading. Will remove it.

ganqqwerty avatar Sep 25 '19 13:09 ganqqwerty

Anyway, the guide is very good 😊 congrats!

Enzaik avatar Sep 25 '19 14:09 Enzaik

@ganqqwerty I came here to create this issue but found there is already a ticket for it. Is this question relevant? Because if we need to shallow copy, can't we just assign it? Eg: var object1 = {a: 1}; var object2 = object1;

akashpjames avatar Jan 12 '20 02:01 akashpjames