Q:

argument missing && || operators in parenthesis but still working

I have come across this piece of code where the if statement contains an argument without && and/or || operators.
if (event.target.scrollTop > 0 !== isViewScrolled) {
    //do something
}

How is it possible that this works? What is the logic contained in the parentheses?

A:

(event.target.scrollTop > 0 returns a bool, so javascript just checks if this bool is equal to isViewScrolled

A:

Check operator precedence https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
According to the above > (greater than) has higher precedence than != (inequality) so the
event.target.scrollTop > 0 !== isViewScrolled

is equivalent to
(event.target.scrollTop > 0) !== isViewScrolled

Although both are equivalent it's best to include parentheses where the order of  evaluation is not clear.

