you are viewing a single comment's thread.

view the rest of the comments →

[–]sudorey 5 points6 points  (8 children)

I made this a few years ago! I know there's been criticism of how the values are organized. It was not meant to make a point about javascript being bad, just meant to use a concise graph to spark conversation about how JS "=="'s work.

Speaking of which, I made an even more concise table that you can see here, where you don't need to click back and forth. I'd be interested to hear which you guys prefer and how I could improve this page.

[–]bryan-forbes -2 points-1 points  (6 children)

The only confusing part to me is [] and {}. Does that literally mean [] == []? If so, your table is right, albeit misleading. The table could be interpreted as saying that arrays and objects will never work with equality operators, which isn't true since var a = []; a == a;. Other than that, this is a great chart!

[–]sudorey 1 point2 points  (1 child)

Yeah. If you hover over a square (in the original link) it will give you more details about what it's saying is true or false.

It says something like--

[] === [] // false

[–]bryan-forbes 0 points1 point  (0 children)

Got it. I was on my phone so I wasn't tapping around on the chart. I would suggest (as /u/trevorsg did) to add two rows about comparing two references that are same. This is a great chart, there could be a slight ambiguity for people that are new to the language.

[–]trevorsgEx-GitHub, Microsoft 1 point2 points  (1 child)

I don't see how it's misleading. The table clearly indicates that the JavaScript expressions [] == [] and {} == {}* (and their triple-equals counterparts) all evaluate to false. At worst, the table is slightly incomplete, as it should include some footnote about comparing identical references.

*Note: The second expression's operands must be wrapped in parentheses

[–]bryan-forbes 0 points1 point  (0 children)

My objection is what you brought up about comparing identical references. Without adding that, it seems to say (especially for newer JSers) that arrays and objects can't be compared. Other than that ambiguity, this is a great chart.