Object.some
Object.some
Function
Determine whether there is a key-value pair in the object so that the callback result is true.
Syntax
object.some(callback)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| callback | Fn | No | Empty | The callback signature is fn(value, key, current). |
Return value
| Type | Description |
|---|---|
| Bool | Returns true if a match exists, false otherwise. |
Example
data = {a: 1, b: 2} result = data.some(fn(value) { value == 2 }) // Output: true print result
Notes
- some does not modify the original object.
- The traversal will stop immediately when the first true result is encountered.