This table is quite useful to solve some problems: https://dorey.github.io/JavaScript-Equality-Table/
JS gets even weirder when you include all the comparison operators. https://jsfiddle.net/5Yzs6/17/ Did you know undefined is equal to undefined, but not = undefined? Or that two instances of the same object/array are not equal (e.g. [-1] != [-1]), but are both = each other? Or that /.*/ is non-comparable (only != is true) to all numbers, but greater than [-0.5] and "-0.5", and less than [0] and "0"?
Return True to Win
91–100 of 123 posts
Re: Return True to Win
#92Did I do it wrong?
Re: Return True to Win
#93Earlier quoted context omitted.
Indeed, I refuse to believe there should be a solution to the 'reflexive' task.
So you disagree with the IEEE floating point specification, then? Javascript is directly following spec there.
Re: Return True to Win
#94Earlier quoted context omitted.
It's because Eich was told to make JS C-like. In C, an empty array, an empty string, 0, false and null are all the same value: a word with all bits 0. So in JS, those are all are falsy and == to each other.
I wish an empty string was not false. In 'object' terms, an empty string is still a string! It's something. I guess if you think about it from a memory perspective, it's 'nothing'. But since JS is not actually like C, I really wish "" were true.
Re: Return True to Win
#95What is with the User/Score/Browser table? I only did like 4 of the tests and that thing popped up. I would finish it but I have some other things to do.
Re: Return True to Win
#96Earlier quoted context omitted.
That one isn't specific to Javascript, though. If you can find a mainstream language that doesn't have any values that aren't equal to themselves, I'll give you a cookie. (Going from memory of the last time I tried this challenge, since I can't get it to load at the moment.)
The important property of evaluation is determinism defined by the equality of the output. Classically, id(x) != id(x) is logically inconsistent. Boolean Logic and natural languages are pretty mainstream in my opinion. Do you mean programming languages? If IEEE whatsthenumber is implemented in the FPUs to provide fcmp (Floating-point Compare Instruction), the languages don't have much of a choice. When there are diff…
It may not seem obvious and it may seem logically inconsistent but, like you said, this is computer science and things don't always work exactly the way we think they should. Usually because the obvious logical solution has problems when implemented so we change things around. In this case, NaN != NaN because of some of the limitations at the time IEEE 754 was proposed.
Re: Return True to Win
#97I typed "true", without the quotes. Did I do it wrong?
Re: Return True to Win
#98What is with the User/Score/Browser table? I only did like 4 of the tests and that thing popped up. I would finish it but I have some other things to do.
Re: Return True to Win
#99Re: Return True to Win
#100Does someone have a <52 char solution for the counter one ?
i=>_=>i=-~i