Object.every
Object.every
Function
Determine whether all key-value pairs in the object make the callback result true.
Syntax
object.every(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 all are true, false otherwise. |
Example
data = {a: 1, b: 2} result = data.every(fn(value) { value > 0 }) // Output: true print result
Notes
- every does not modify the original object.
- The traversal will stop immediately upon encountering the first false value result.