Skip to content

Instantly share code, notes, and snippets.

@jennazee
Last active May 20, 2016 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jennazee/ee46235298fd59ad3333e9e8ab955add to your computer and use it in GitHub Desktop.
Save jennazee/ee46235298fd59ad3333e9e8ab955add to your computer and use it in GitHub Desktop.

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