- partition<T>(arr: T[], fn: ((value: T, index: number, array: T[]) => boolean)): [T[], T[]]
-
Parameters
-
arr: T[]
-
fn: ((value: T, index: number, array: T[]) => boolean)
-
- (value: T, index: number, array: T[]): boolean
-
Parameters
-
value: T
-
index: number
-
array: T[]
Returns boolean
Returns [T[], T[]]
Groups the elements into two arrays, depending on the provided function's truthiness for each element
Example