If statements and functions

An example of this is De Morgan’s Law, for boolean manipulation.

!x && !y === !(x || y)

I’d actually kind of worked it out in my head just by experience and sitting down and pumping a logic matrix through some functions. It was a joy when I discovered that it is an actual law. It’s also fun to pull out in code reviews of junior devs and simplify their logic - they think I’m some kind of wizard.

Just keep at it, you’ll accumulate little things like this.


So the symbole ! when it is added to a value, what does it do? I know the unequal sign != . So when you write !x it means it not true or what?
Thank you.

Yup. The ! flips the boolean value of the statement, so !true === false.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.