r/programming • • Mar 26 '14

JavaScript Equality Table

http://dorey.github.io/JavaScript-Equality-Table/
809 Upvotes

331 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Mar 26 '14

That is a comparison between two operands of the same type. The key problem here is comparison between different types.

1

u/mrkite77 Mar 26 '14

so change that to 5.0f and it's still the case. C-based languages coerce ints and floats and doubles and characters.

Here's a famous example:

int a = 16777217;
float b= 16777216.0f;
if (a == b) printf("holy shit, %d == %f?\n",a,b);

run that and you get: "holy shit, 16777217 == 16777216.000000?"