DEV Community

Discussion on: Equality of Data Structures: Ruby vs. JavaScript

Collapse
 
tsupinie profile image
Tim Supinie

I guess isn't Javascript's == operator supposed to be an "is this the same stuff in the box" check? There's all this implicit typecasting going on, but at its heart, it's an equality check designed to determine if two variables contain the same value. So I'm not sure you can draw the conclusion of philosophical differences in language design when Javascript has an operator with the same intent as in Ruby.

Collapse
 
annarankin profile image
Anna Rankin

Hi Tim, good point! However, if you try out [1,2,3] == [1,2,3] in your console, you'll see it returns false. JS's double-equals will coerce types, but it won't perform a recursive equality check the way it does in Ruby. 😵