Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Created September 30, 2014 19:46
Show Gist options
  • Save bloodyowl/3af1cb0845e70c271e30 to your computer and use it in GitHub Desktop.
Save bloodyowl/3af1cb0845e70c271e30 to your computer and use it in GitHub Desktop.
how coding styles change …
function contains(value){
var self = this
, index = 0, l = self.length
for(;index < l; index++) if(value === self[index]) return true
return false
}
// …
Array.prototype.contains = contains
function arrayContains(array, value){
if(!Array.isArray(array)) {
throw new TypeError()
}
var index = -1
var length = array.length
while(++index < length){
if(value === array[index]) {
return true
}
}
return false
}
module.exports = arrayContains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment