Created
September 30, 2014 19:46
-
-
Save bloodyowl/3af1cb0845e70c271e30 to your computer and use it in GitHub Desktop.
how coding styles change …
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
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 |
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
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