-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathnone.js
More file actions
28 lines (21 loc) · 783 Bytes
/
none.js
File metadata and controls
28 lines (21 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
*
none() exectues a provided *predicate* on each element of
the array until it is fulfilled.
none() has two parameters:
- the predicate callback function
- a *this* argument for the callback. If none is provided, *this* will not be set in the predicate
The predicate function one to three arguments:
- the value of current element
- the index of the current element
- the Array object being traversed
If the predicate is fulfilled then the method will exit early (and return false).
Calling none on an empty array will return true.
*/
Array.prototype.myNone = function myNone(predicate, thisArg){
for(var i = 0 ; i < this.length ; ++i){
if(predicate.call(thisArg, this[i], i, this))
return false;
}
return true;
}