@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
13 lines (12 loc) • 397 B
JavaScript
/**
* Returns the last non-null element in an array.
* @param data - An array of any type
* @returns The last element that is neither null nor undefined, or undefined if no such element exists
* @example
* last([1, 2, null]) // Returns 2
* last([]) // Returns undefined
* last([null, undefined]) // Returns undefined
*/
export function last(d) {
return d.findLast((c) => c != null);
}