indexOf vs list of conditions

Edit on GitHub

Setup

var x = ~~(Math.random() * 10);

Tests

  • indexOf

    if([0,1].indexOf(x))
  • list of conditions

    if(x == 0 || x == 1)