Array.prototype.includes vs Array.prototype.indexOf

Edit on GitHub

Setup

var data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Tests

  • Array.prototype.includes

    data.includes(2)
  • Array.prototype.indexOf

    data.indexOf(2) > -1