[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [lengthOf](./js-utils.lengthof.md)
## lengthOf() function
Calculate the length of an array or value.
Arrays return their length, single values return 1, and nil values return 0. This counts the number of elements that setOrPush would add.
Signature:
```typescript
export declare function lengthOf(val: Maybe): number;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | [Maybe](./js-utils.maybe.md)<unknown> | |
Returns:
number