Arrays in loop

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array inside
function isKnownBot(ua) {
  const bots = [
    'Googlebot',
    'TelegramBot',
    'WhatsApp',
    'BingPreview',
    'bingbot',
    'LinkedInBot',
    'TwitterBot',
    'adidxbot',
    'duckduckgo',
    'msnbot',
    'YandexBot',
    'YandexImage',
    'AdsBot-Google',
    'Google-HTTP-Java-Client',
    'Google-Read-Aloud',
    'Applebot',
  ];

  return bots.some(bot => ua.includes(bot));
}

isKnownBot(
  (Math.random() + 1).toString(36).substring(7)
)
ready
Array outside
const bots = [
    'Googlebot',
    'TelegramBot',
    'WhatsApp',
    'BingPreview',
    'bingbot',
    'LinkedInBot',
    'TwitterBot',
    'adidxbot',
    'duckduckgo',
    'msnbot',
    'YandexBot',
    'YandexImage',
    'AdsBot-Google',
    'Google-HTTP-Java-Client',
    'Google-Read-Aloud',
    'Applebot',
  ];
 
function isKnownBot(ua) {
  return bots.some(bot => ua.includes(bot));
}

isKnownBot(
  (Math.random() + 1).toString(36).substring(7)
)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.