some markdown text
Last active
November 29, 2016 12:12
-
-
Save karlpokus/7491521d27af27bddd6f5c98a5f63560 to your computer and use it in GitHub Desktop.
implementation of indexof in js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.indexOff = function(x) { | |
if (this.length === 0) { | |
return -1 | |
} | |
for (var i = 0; i < this.length; i++) { | |
if (this[i] === x) { | |
return i | |
} | |
} | |
return -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment