https://github.com/jonschlinkert/for-in
Iterate over the enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`.
https://github.com/jonschlinkert/for-in
for-in forin iterate keys object values
Last synced: about 2 months ago
JSON representation
Iterate over the enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`.
- Host: GitHub
- URL: https://github.com/jonschlinkert/for-in
- Owner: jonschlinkert
- License: mit
- Created: 2014-09-20T23:28:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-28T16:13:29.000Z (over 8 years ago)
- Last Synced: 2025-03-24T00:08:09.447Z (3 months ago)
- Topics: for-in, forin, iterate, keys, object, values
- Language: JavaScript
- Size: 14.6 KB
- Stars: 35
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# for-in [](https://www.npmjs.com/package/for-in) [](https://npmjs.org/package/for-in) [](https://npmjs.org/package/for-in) [](https://travis-ci.org/jonschlinkert/for-in)
> Iterate over the own and inherited enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save for-in
```## Usage
```js
var forIn = require('for-in');var obj = {a: 'foo', b: 'bar', c: 'baz'};
var values = [];
var keys = [];forIn(obj, function (value, key, o) {
keys.push(key);
values.push(value);
});console.log(keys);
//=> ['a', 'b', 'c'];console.log(values);
//=> ['foo', 'bar', 'baz'];
```## About
### Related projects
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.")
* [collection-map](https://www.npmjs.com/package/collection-map): Returns an array of mapped values from an array or object. | [homepage](https://github.com/jonschlinkert/collection-map "Returns an array of mapped values from an array or object.")
* [for-own](https://www.npmjs.com/package/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own) | [homepage](https://github.com/jonschlinkert/for-own "Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js.")### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 16 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [paulirish](https://github.com/paulirish) |### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 28, 2017._