Last active
September 6, 2021 07:39
-
-
Save saravanapriyanm/1c82eb52aa8fc685f4ecba4c7fdf87f5 to your computer and use it in GitHub Desktop.
JS Performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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