Posts

Showing posts with the label reference

Will two objects/arrays in javascript == each other by coincidence?

Will two objects/arrays in javascript == each other by coincidence? Lets say I have array a. var a = [1,2,3]; And then there is array b. var b = [1,2,3]; Is there ANY possible chance that a == b will return true? Even if it is one in a million. (I know that normally a == b will be false, but I am wondering if there is a chance that it will be true.) a == b a == b No, because if the objects are referencable, they haven't been garbage collected - the objects in memory they reference must be separate. – CertainPerformance Jul 2 at 0:39 wondering if there is a chance that it will be true - absolutely zero "chance" - programming languages are not a lottery, they have a defined behaviour, and by definition of the javascript language, in the proposed scenario, a does not equal b...