Created
July 5, 2017 08:19
-
-
Save linkin-park/9ab282c34fb64e516a85cab0838d0ab1 to your computer and use it in GitHub Desktop.
JS - ProtoType
This file contains 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 | |
Array.prototype.every = function(f){ | |
//isevery = false; // intially set to false | |
for(let i=0;i<this.length;i++) | |
if(!f(this[i])) return false; // onfailing it returns false | |
return true; | |
} | |
Array.prototype.some = function(f){ | |
issome = false; // intially set to false | |
for(let i=0;i<this.length;i++) | |
if(f(this[i])) return !issome; | |
return issome; | |
} | |
//some.call([1,2,3],(a)=>{return a>3;}) | |
//every.call([1,2,3,4],(a)=>{return a+1>-1}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment