This is a lot of normal behavior that people don't understand.
js> Array(3)==",,"
true
That is fully expected, you are comparing the value of an array which would be represented as [",,"] so without checking the types, this is exactly what you should get.
ex.
js>Array(3)===",,"
false
------------------
The issue with something like
js> 9999999999999999
10000000000000000
is that the largest exact number available is 9007199254740992 due to the fact that javascript uses double-precision floating-point numbers. http://ecma262-5.com/ELS5_HTML.htm#Section_8.5 ------------------
Now, there is a perfectly valid reason why this is an expected result:
js> 0.1+0.2==0.3
false
The issue is that the first subject of addition isn't actually just 0.1, it's actually 0.100000000000000005551
same with 0.2, it's actually value is
0.200000000000000011102
if you execute 0.1 it will say 0.1 due to the fact that javascript has a default precision size to show you which is the length of your input OR 1 if it's over 18.
If you execute 0.10000000000000006
it will return 0.10000000000000006
however
if you execute 0.100000000000000006 (one more precision)
it will return 0.1
That is fully expected, you are comparing the
------------------value
of an array which would be represented as [",,"] so without checking the types, this is exactly what you should get. ex.The issue with something like
is that the largest exact number available is 9007199254740992 due to the fact that javascript uses double-precision floating-point numbers. http://ecma262-5.com/ELS5_HTML.htm#Section_8.5
------------------
Now, there is a perfectly valid reason why this is an expected result:
The issue is that the first subject of addition isn't actually just 0.1, it's actually
0.100000000000000005551 same with 0.2, it's actually value is 0.200000000000000011102 if you execute
0.1
it will say0.1
due to the fact that javascript has a default precision size to show you which is the length of your input OR 1 if it's over 18.If you execute
0.10000000000000006
it will return0.10000000000000006
however if you execute0.100000000000000006
(one more precision) it will return0.1
Now, here is what is actually happening
Now that makes more sense, it was just hidden by the way JS chooses to show numbers. Python suffers from the same situation.
So in conclusion 0.1+0.2 is not equal to 0.3, it's equal to 0.300000000000000044409
------------------From a high level I see why the following example is the case
So []+[] returning a string is normal, but what about when you check the typeof []+[] ...?
welp, that's sure not a string BUT, what about when you assign []+[] to a variable and