Sunday, 12 February 2017

javascript - Using operators as variables gives odd results

! + [] === true



Can someone explain what's happening here? I understand this is not normal, but I'm struggling to understand what the compiler is doing when it seems operators used in place of variables in mathematical operations.



more examples of this strangeness:



(! + '') === (!'')


but



(! + []) !== (![])

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...