Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Latest commit

 

History

History
55 lines (45 loc) · 2.06 KB

forOwn.md

File metadata and controls

55 lines (45 loc) · 2.06 KB

Object Agent

A javascript library for working with objects

npm build coverage deps size vulnerabilities license


forOwn(object, callback) ⇒ Boolean

Iterates over own properties of an object. Stops iterating as soon as the callback returns a truthy value.

Returns: Boolean - true if the callback function returns a truthy value for any key; otherwise, false.

Param Type Description
object Object
callback function Provides two args: value and key

Example

import { forOwn } from 'object-agent';

const thing = {
    a: 'b',
    c: 'd'
};

forOwn(thing, (value, key) => {
    console.log(value, key);
});
// => 'b', 'a'
// => 'd', 'c'