if ( array_contains(list, "foo") ) { ... }
This function provides an array.contains method that JavaScript lacks.
See also Functions.