Test for value in Javascript Array [duplicate] March 4, 2023 by Tarik Use indexOf to see if x is in an array. if([1,2].indexOf(x) !== -1)