null is one of a few ‘falsy’ values in JavaScript, including NaN, false, 0, “” and undefined. When JavaScript is asked to coerce a value to bool, which if
does, the value is checked against falsy values, but is otherwise considered ‘truthy’. Your null was falsy, you used !
to ‘not’ it, making it true.
solved Why is !null true when var is null per default [closed]