Includes vs IndexOf vs Contains vs typeof

Edit on GitHub

Setup

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

Tests

  • Includes

    data.includes(2)
  • IndexOf

    data.indexOf(2) > -1
  • typeof

    typeof data[2] !== 'undefined'