4
I was watching a video that was shown to me by the user @CiganoMorrisonMendez
, called WAT.
There were some examples where they showed some bizarre things present in some languages.
In particular what caught my attention was this line of Javascript:
{} + [] // Resultado: 0
By adding a objeto
with a array
the value 0
is returned. It may even seem unaware this, but I want to know the explanation for this, since for this question there’s also an explanation for the weirdness.
What is the reason for this behavior? I would like a step-by-step explanation like the above-mentioned question.
Empty = False, False = 0, 0 + 0 = 0.
– Laerte