## trimTrailingEmptyElements() function [​](/content/docs/sdk/core.trimtrailingemptyelements#trimtrailingemptyelements-function "Direct link to trimTrailingEmptyElements(/index.html) 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:**

```typescript
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.

- [trimTrailingEmptyElements() function](/content/docs/sdk/core.trimtrailingemptyelements#trimtrailingemptyelements-function/index.html)
- [Parameters](/content/docs/sdk/core.trimtrailingemptyelements#parameters/index.html)
