Now let’s discuss a few weird stuff it includes.
> '5' - 3 < 2
> '5' + 3 < "53"
But what happens here? Why are we getting 53? Well in this case, 3 was implicitly cast to a string and we have string concatenation instead of integer math.
So the first case converted '5' to 5 and the second case 3 to '3'.
What about this?
> '5' - '3' < 2
Ok now let's try something else.
> '5' + + '4' < '54'
Ok the + + did not change anything in the end, we still get string concatenation. So what would happen if we tried with two strings?
> 'foo' + + 'bar' < 'fooNaN'
Wait what? So in the first case it works but in the second it does not? Yes, because in the first case, the number 4 was converted to an integer and the back to string in order to be concatenated with '5'. Why? Because of this
> + '4' < 4
> '5' + -'4' < '5-4'
Yup. Makes sense does it not?
-'4' gets converted to -4 and then back to '-4'.
> var x=3 < undefined > '5' -x + x < 5 > '5' + x - x < 50
What is happening here? Well here we see a simple butchering of math.
Let's move one to other stuff.
> typeof NaN < "number" > NaN == NaN < false
Ok, so the type of Not a Number is a number? And it also does not equal itself? Oh, well. Let's try equality with other stuff.
> x= <  > x == x < true
Ok so far. Makes sense that an array with only one value in will equal itself. Continuing on the above example let's try this
> x == !x < true
Wait so x equals itself, but also equals not itself?
Ok. What about the following?
> Array(3)==",," < true
Great, nice, awesome....
So what is null really?
> typeof null < "object"
Ok, so which means
> null instanceof Object < false
Wait, typeof null is object, but null is not an instance of Object? Ok. But surely this would make more sense with a string.
Ok, so which means
> "string" instanceof String < false
No? ok then. Let's try some max and min values.
> Math.max() > Math.min() < false > Math.max() < Math.min() < true
Really? So the max value of math is smaller than the min value of math? Great.
Shall we try some booleans now?
First lets establish a baseline
> true == false < false > false == false < true > true == true < true
Ok, booleans seem ok, let's try something else.
> true && false < false > true && true < true > true && NaN < NaN
Really? true AND NaN produces NaN instead of a boolean?
> false && NaN < false
Let's try something weird.
> true + true === 2 < true > true - true === 0 < true
So from this one would assume that true is equal to 1 right? Let's check that
> true === 1 < false
How dare you make assumptions in language which the only thing it is consistent about is its inconsistency?
I must probably will do a round 2 some time in the future.
Excercise for home, can you find out what the following will output and why without running it?
Let me know in the comments.