Looping vs String contains

Edit on GitHub

Setup

var search = 'name=Bill&job=Whaaaaat&dom=loc';

Tests

  • Looping

    var queryStrings = search.split('&');
        for (var i = 0; i < queryStrings.length; i++) {
          var valuePair = queryStrings[i].split('=');
          if (valuePair[0] === 'no-track-click') {
            return true;
            break;
          }
        }
        return false;
  • String contains

    return search.indexOf('no-track-click') !== -1;