How to write JavaScript indexOf and lastIndexOf array methods from scratch
Dec 6, 2023 · 1 min read · indexOf Returns first index of the found element otherwise -1. Array.prototype._indexOf = function(searchElement, fromIndex = 0) { for(let i = fromIndex; i < this.length; i++) { if(searchElement === this[i]) { return i ...
Join discussion