سؤال

I want to know how top.location and self.location is compared. I mean on what basis are they compared?

Are they compared using their memory address or their references or something else? Basically, i want to know when (top.location == self.location) will give true and when the comparison will give false?

I know all those stuff that says they are compared using their respective url and all that. But the thing is they are objects. And hence, it would be interesting to know how objects are compared?

هل كانت مفيدة؟

المحلول

Objects, arrays and functions are copied, passed and compared by reference in Javascrpt iirc. So top === self as they reference the same object. And from that it is clear that the equality of top.location === self.location must hold as well.

References

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top