Javascript Array includes(searchElement, fromIndex = 0)
Array.prototype.includes = function(searchElement, fromIndex = 0) { let arr = this;/* w w w . j av a2 s. c o m*/ let result = false; let start = Math.max(fromIndex < 0 ? fromIndex + arr.length : fromIndex, 0); for (let i = start, len = arr.length; i < len; i++) { if (arr[i] === searchElement) { result = true; break; } } return result; }