getPropertyFromItem

Commons
stable

Extracts a value from a data item using a flexible TSelectItemKey accessor — a string path, an array path, a boolean identity flag, or a custom extractor function — with a fallback for missing values.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

item
required
any
The data item (object, primitive, or array) to extract a value from.
property
required
TSelectItemKey
The key accessor. true = return the item itself; string = dot-path; string[] = nested path; function = custom extractor. null, undefined, or false returns the fallback.
fallback
any
Value returned when the property cannot be resolved. Defaults to undefined.

API

Return value

The value returned by this util.

The extracted value, the item itself (when property is true), or the fallback.

Usage

Examples

Ready-to-paste usage snippets.

Extract label and value from a select item

typescript