has

utility

Checks if an object contains a key

Syntax

has(container, key)

Parameters

container (object)

The object to check

key (string)

The key to look for

Returns

boolean

True if the key exists, false otherwise

Examples

Check if object has a key
Input:
{name: "Alice"} | has("name")
Output:
true
Filter rows with email field
Input:
map(select(has("email")))
Output:
[{name: "Alice", email: "[email protected]"}]

The has() function checks whether an object contains a specific key or property.

Usage

Use has() to validate the presence of fields before accessing them, or to filter data based on field existence.

Related Functions