while case is the fastest Copy the code code as follows: function contains(arr, str) { var i = arr.length; while (i--) { if (arr[i] === str) { return true; } } return false; }