Includes indexOf vs Includes Match

Edit on GitHub

Setup

function includesIndexOf(a, b) {
    return a.match(b) !== null;
}

function includesMatch(a, b) {
    return a.match(b) !== null;
}

Tests

  • Includes indexOf

    includesIndexOf('abcdefg', 'cde');
  • Includes Match

    includesMatch('abcdefg', 'cde');