$slice

The `$slice` operator returns a subset of an array.

Syntax

{ $slice: [ <array>, <n> ] }

Parameters

<array>stringrequired

Any valid expression that resolves to an array.

<n>numberrequired

Any valid expression that resolves to an integer. If positive, returns the first n elements. If negative, returns the last n elements.