I am editing someone's code and I don't understand what they are trying to do with this statement. This is at the end of the function.
return !(this.variable == "value")
I am editing someone's code and I don't understand what they are trying to do with this statement. This is at the end of the function.
return !(this.variable == "value")
They're returning true or false based on the opposite of the result of the comparison.
It would probably have been clearer to write:
return this.variable != "value";
Sometimes you see:
return !!(some.expression);
which forces a "truthiness" conversion of the result of the expression to boolean (true or false). The "!!" is just a pair of individual logical complement ("not") operators. The first one (on the right) converts the result of the expression to boolean, but the opposite of the "truthiness". The second therefore flips it back.
=== (and !=== in your rewrite).== comparison. I'll coerce things explicitly if I want coercion, and leave off the relational entirely if I only care about Boolean interpretation.