core.trimtrailingemptyelements | Medplum
trimTrailingEmptyElements() function
Returns an array with trailing empty elements removed. For example, [1, 2, 3, null, undefined, ''] becomes [1, 2, 3]. This is useful for FHIR arrays, which by default must maintain the same length, but while editing we may want to trim trailing empty elements.
Signature:
export declare function trimTrailingEmptyElements<T>(arr: T[] | undefined): T[] | undefined;
Parameters [](/content/docs/sdk/core.trimtrailingemptyelements#parameters "Direct link to Parameters"/index.html)
| Parameter | Type | Description |
|---|---|---|
| arr | T[] | The input array. |
Returns:
T[] | undefined
The array with trailing empty elements removed.