function myIncludes(element) { const isThisArray = Array.isArray(this) if (isThisArray) { for (let i = 0; i < this.length; i++){ if (this[i] === element) { return true; } } } else { for (let i = 0; i < this.length; i++){ if (this[i] === element[0]) { for (let j = 1; j < element.length; j++){ if (this[i + j] !== element[j]) { return false } } return true; } } } return false; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter