param source param predicate returns export const lastOrDefault = < TSource > ( source , predicate ? ) : TSource | null => { if ( predicate ) { return lastOrDefault2 ( source , predicate ) ; } else { return lastOrDefault1 ( source ) ; } } ; const lastOrDefault1 = < TSource > ( source ) : TSource | null => { let last = null ; for ( const value of source ) { last = value ; } return last ; } ; const lastOrDefault2 = < TSource > ( source , predicate ) : TSource | null => { let last = null ; for ( const value of source ) { if ( predicate ( value ) === true ) { last = value ; } } return last ; } ;