Object.find_key
Object.find_key
Function
Returns the first key name for which the callback result is true.
Syntax
object.find_key(callback)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| callback | Fn | No | Empty | The callback signature is fn(value, key, current). |
Return value
| Type | Description |
|---|---|
| String/Empty | Returns the key name if found, otherwise returns Empty. |
Example
data = {a: 1, b: 2, c: 3} result = data.find_key(fn(value) { value > 1 }) // Output: b print result
Notes
- find_key traverses objects in order of insertion.
- The traversal stops as soon as the first matching key is found.