wynd — 10/18/2022, 10:45:00 PM

answered: arrays cant be checked for equality, thanks oren

does anyone here know why

[typeof "this is a string", typeof "also a string"] == ['string', 'string']

returns false?

♥ 2 ↩ 0 💬 8 comments

comments

gosoccerboy6:

Reference instead of value equality

10/24/2022, 12:40:59 PM
pkmnq:

If you want to know why arrays can’t be checked for equality, it’s because two objects must be the exact same for == to return true

For example:

[] == [] // false
x = []; x == x // true
10/19/2022, 2:33:48 AM
oren:
["string", "string"] == ['string', 'string'] // false
"s" == 's' // true
10/18/2022, 10:54:54 PM
oren:
['s','a']==['s','a'] //false
10/18/2022, 10:56:30 PM
oren:
['a']==['a'] //false
10/18/2022, 10:57:06 PM
oren:

I guess arrays just cant be checked for equality

10/18/2022, 10:57:44 PM
wynd:

oh, good thing i found a different way to find what i was looking for

10/18/2022, 10:58:47 PM
oren:

yeah I looked it up, they cant

10/18/2022, 11:01:01 PM