|
I guess the good news is that no one else is seeing the same issue. The bad news is I still don't know what's causing it. If I ever find out I'll be sure to mention it.
|
|
|
|
|
Recently had been debugging using the browser console, when I found this answer.
Can you guess the type of foo here? Is it a string, function or else?
|
|
|
|
|
By definition undefined should be unequal to undefined.
Is it?
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
Nope, `undefined` is not the answer.
Since `undefined == undefined` returns true in console.
|
|
|
|
|
Ok, I googled it. It's NaN!
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
Your are very near, but this is not the exact answer
|
|
|
|
|
That's bullshit! I've tried it out and surely foo!=foo is true if foo is NaN.
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
Yup, you are right but here foo is actually NaN, but the question is `What is type of foo`
So, the real answer is `number`
Since, typeof NaN returns "number"
Cheers!
|
|
|
|
|
Isn't it amazing, how NaN is a number, how a number is a word and how a word is a string.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
yup, the NaN stuff is amazing, but not sure about 'how a number is a word and how a word is a string'
|
|
|
|
|
Great that you already know the NaN is a number.
Now, if you have ever programmed in low-level, you would know that a word is a size given to a data, 1 byte, 2 byte etc. So the size of the register in CPU is a word; pre-defined size, doesn't matter 8-bit 16-bit or what. The size is number, thus, a number is word.
Now a word in our language, for example, "Hello", cannot be represented as a word in computer which needs some other type, which is string (array of characters), thus a word is a string. From here comes the metaphor,
In programming, a number is a word and a word is a string.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Do you have any reference documentations for it?
I want to learn about it more in-depth. Thanks!
|
|
|
|
|
Sure, read about Word in computer architecture[^] and the string data type[^]. One thing you should know is that there is no actual string type, it is just an array of characters.
Good luck for more in-depths.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Thanks for it. Have a nice day ahead!
|
|
|
|
|
Great explanation of how semantics and jargon are sometimes or often at odds with meaning.
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: Isn't it amazing, how NaN is a number Yes! Especially since NaN is short for "Not a Number"!
My whole life is a lie!
|
|
|
|
|
Clarified, but how is a number a word (the size of register) and how is a word actually a string (the data type)?
Plus, short form of your life is a lie (removing the F).
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
No, undefined compared with anything (anything includes also again undefined) is "an error" and therefore neither equal nor unequal... it is simply again undefined.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
It's 2015, IEEE 754 is from 1985, how does this still surprise people after 30 years?
|
|
|
|
|
Any after overloading operators...
|
|
|
|
|
spoiler alert -- answer is below
Opened Chrome Dev console and ran the following.
var x = 'garbage' / 10;
x
NaN
x != x
true
x !== x
true
typeof(x)
"number"
|
|
|
|
|
Awesome
|
|
|
|
|
How about int ?
private static System.Random randy = new System.Random() ;
int foo { get { return ( randy.Next() ) ; } }
|
|
|
|
|
Or DateTime:
DateTime foo { get { return DateTime.Now; } }
|
|
|
|
|