Inside my node.js REPL I create 4 arrays :
a = [1,2,3], b=[], c=[4,5], d=null ( ok d is not an array but you get my point)
I compare them directly this way :
> b = []
[]
> a > b
true
> b > a
false
> a > c
false
> c > a
true
> c > b
true
> b > c
false
> d > a
false
> a > d
false
What are these expressions actually evaluating?
I see that it's clearly not the length of the arrays. Otherwise c > a would have been false.
Can somebody please help me understand!
operator>evaluation. Since these results don't have any valuable semantic meaning, it's basically a pointless operation and you should create your own routine for comparing arrays if you need that functionality. There isn't much point in further stressing why JavaScript chooses to implement things this way, as there are many other examples of weird JavaScript behavior.