Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Last active November 29, 2016 12:12
Show Gist options
  • Save karlpokus/7491521d27af27bddd6f5c98a5f63560 to your computer and use it in GitHub Desktop.
Save karlpokus/7491521d27af27bddd6f5c98a5f63560 to your computer and use it in GitHub Desktop.
implementation of indexof in js
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
}

this is a test

some markdown text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment