ObjectConstructor.each method
ObjectConstructor › each
Official
Check if all properties in an object satisfy a condition.Signature:
each(object: Record<string, T>, callback: (value: T, key?: string | undefined) => boolean | void, context?: unknown): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
| object | Record<string, T> | The object to check. |
| callback | (value: T, key?: string | undefined) => boolean | void | The condition to check. |
| context? | unknown | The context passed as this to the callback. |
Returns: boolean — true if all properties satisfy the condition, false otherwise.
Example:
console.log(Object.each({ a: 1, b: 2 }, function(value) { return value > this.min }, { min: 0 })); // trueconsole.log(Object.each({ a: 1, b: 2 }, function(value) { return value > this.min }, { min: 1 }); // false