Skip to content

Latest commit

 

History

History
56 lines (45 loc) · 2.12 KB

forIn.md

File metadata and controls

56 lines (45 loc) · 2.12 KB

Object Agent

A javascript library for working with objects

npm build coverage deps size vulnerabilities license


forIn(object, callback) ⇒ boolean

Iterates over own and inherited 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 The object to iterate over.
callback function Provides two args: value and key.

Example

import { forIn } from 'object-agent';

const Thing = {
    this.a = 'b';
};

Thing.prototype.c = 'd';

forIn(new Thing(), (value, key) => {
    console.log(value, key);
});
// => 'b', 'a'
// => 'd', 'c'