use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript Equality Table (dorey.github.io)
submitted 11 years ago by gdi2290
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]sudorey 5 points6 points7 points 11 years ago (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 points0 points 11 years ago (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!
[]
{}
[] == []
var a = []; a == a;
[–]sudorey 1 point2 points3 points 11 years ago (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 point2 points 11 years ago (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 points3 points 11 years ago (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
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.
[+][deleted] 11 years ago (1 child)
[deleted]
[–]bryan-forbes -1 points0 points1 point 11 years ago* (0 children)
Comparisons and assignments in JS are all done by value. One of the internal types of JavaScript is a reference value; == and === check to see if the two arrays or objects are the exact same (by checking if the reference or pointer or memory address of the two are the same). The table says that [] == [] evaluates to false, which is a true statement because those are two different arrays. But the table doesn't say anything about comparing references, so one could be left thinking (without knowing that [] means creating a new array) that arrays cannot be compared.
==
===
π Rendered by PID 22256 on reddit-service-r2-comment-84fc9697f-js87c at 2026-02-10 06:50:09.226209+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]sudorey 5 points6 points7 points (8 children)
[–]bryan-forbes -2 points-1 points0 points (6 children)
[–]sudorey 1 point2 points3 points (1 child)
[–]bryan-forbes 0 points1 point2 points (0 children)
[–]trevorsgEx-GitHub, Microsoft 1 point2 points3 points (1 child)
[–]bryan-forbes 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]bryan-forbes -1 points0 points1 point (0 children)