Skip to main content
Documentation home page
Search...
⌘K
Support
Console
Console
Search...
Navigation
Documentation
API Reference
MMQL
MMQL Queries
Overview
MMQL Operators
Operators
Logical Operators
Comparison Operators
Arithmetic Operators
Aggregation Operators
Bitwise Operators
String Operators
Time/Date Operators
Array Operators
First
Last
Nth
Filter
Map
Reduce
Find
Every
Some
Object Operators
Value Checking Operators
Type Conversion Operators
Conditional Operators
Random Operator
Math Operators
UUID and Hash Operators
Constant Operators
Block Operators
Input Operator
On this page
$last
Input
Output
Examples
Get Last Element
From Field
Array Operators
Last
$last
The
$last
operator returns the last element of an array.
Input
A single array value
Output
The last element of the array, or null if the array is empty
Examples
Get Last Element
Copy
{
"$last"
: [
[
1
,
2
,
3
,
4
,
5
]
]
}
Result:
5
From Field
Copy
{
"$last"
: [
{
"$input"
:
"items"
}
]
}
Result: The last element of the items field array, or null if the array is empty
First
Nth
⌘I