Skip to content

Instantly share code, notes, and snippets.

@jennazee jennazee/demorgans.md
Last active May 20, 2016

Embed
What would you like to do?

I wanted to do not something if the PerformanceTiming object wasn't available, so I started with something like this:

if (!window.performance || !window.performance.timing) {
    return;
}

DeMorgans law says that you can factor out the "not" and then flip the "and" to an "or" or vice versa. So, I was able to switch it to

if (!(window.performance && window.performance.timing)) {
    return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.