Skip to content

Instantly share code, notes, and snippets.

@saravanapriyanm
Last active September 6, 2021 07:39
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 saravanapriyanm/1c82eb52aa8fc685f4ecba4c7fdf87f5 to your computer and use it in GitHub Desktop.
Save saravanapriyanm/1c82eb52aa8fc685f4ecba4c7fdf87f5 to your computer and use it in GitHub Desktop.
JS Performance
const stat = 'Pending';
console.time('OR');
console.log(stat === 'Pending' || stat === 'No Tweets Found' || stat === 'Error. Please retry.')
console.timeEnd('OR');
// Faster & Shorter
console.time('includes');
console.log(['Pending', 'No Tweets Found', 'Error. Please retry.'].includes(stat))
console.timeEnd('includes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment