Thank you for restoring order in the world for me (or rather: making me see it).
I am also drawing a lesson for my own thinking: it should have been possible for me to at least come closer to that explanation. If js is comparing two things that apparently are the same but doesn’t see them as the same, it is reasonable to ask something like: well, how does it see them? Or: How does it compare them. And searching for comparison in js might have brought up that explanation.
So why did I not ask those questions? At a general level, I guess it has to do with me not knowing any javascript, plus not even being sure how much of dataviewjs is actual javascript and how much of it is specific to dataviewjs. For example, I think I saw that the date()
-function exists in javascript but didn’t quite understand what it meant that in dataviewjs, we use dv.date()
. So given that I understood how little I understood, I knew I avoided going down rabbit holes that were likely to keep me busy for a long time and without necessarily giving me a solution to the specific problem at hand. Another way of putting this is: I was looking for relatively quick answers because my objective here was not to learn javascript in general but rather to understand this specific thing.
So, I think that avoidance of rabbit holes contributed to my failure to figure this out, and I don’t blame myself for it. But what is to be learned from this nonetheless is that this is where the value of discussion forums like this one lies: it allows people in situations like mine (trying to understand stuff without going down (too many) rabbit holes) to simply ask for help. The art is in finding the right moment in your thought process to “give up” and ask. While some people would do better if they invested a little more energy into trying to find the answer themselves, I should probably reach out a bit earlier, because the the learning curve seems to be logistic (not logarithmic - you need to invest some thought before seeing some light, and certainly not exponential - there are certainly limits to your learning) and once I’ve past the steep part of the curve, I’m into seriously diminishing returns and this is where help from others can help expand what they call the carrying capacity.
But coming back to the specific problem here and why I didn’t manage to solve it: when I was looking at the representations of the dates in the console, I didn’t really know what I was looking at. For example, I wondered which of the “branches” of this tree were part of the actual date array, and which of them were just calculated for display. In some cases it was obvious when the fields were filled in only when I clicked on them. At some point, I suspected that the date may in fact just be stored as a time stamp and everything else is calculated when needed, but the presence of data about locale and what not made me rule that one out. Also, it would have been even less logical for the comparison to fail if the raw data was just a number.
So this is where I think I could have come up with one of the questions above. In fact, I did sort of ask myself that, but dismissed it as one of those rabbit holes that is unlikely to lead me to the solution I was looking for. So why did I make this (faulty) judgement?
It is actually pretty clear to me: it is because this was about only one specific comparison (==
) and not others. I seemed unlikely that this had something to do with how js sees those arrays, because why would it see them differently in different kinds of comparison? So, I didn’t feel a need to understand how js reads that array (or whatever it is) since it would obviously do so in a consistent way.
And I actually still don’t understand why checking for equality is done according to a different logic than than other comparisons. Could you elaborate @holroy? (I found a technical explanation here, but maybe you have a more high level explanation for why this is so or why this makes sense?)