# for-each

> A better forEach

Latest version **0.3.5** (published 2025-02-11) · MIT license · 0 weekly downloads

> **Native alternative:** for...of (using "Object.entries" if dealing with objects) — Use native JavaScript (Node 0.12.0+) (https://developer.mozilla.orgStatements/for...of)

## Install

```sh
npm install for-each
pnpm add for-each
yarn add for-each
bun add for-each
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.5 |
| Published | 2025-02-11 |
| First published | 2012-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 1 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Raynos |
| Maintainers | raynos, ljharb |

## Links

- npm: https://www.npmjs.com/package/for-each
- Repository: https://github.com/Raynos/for-each
- Issues: https://github.com/Raynos/for-each/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/for-each

## Dependencies (1)

- [is-callable](https://npm.io/package/is-callable.md) ^1.2.7

## Recent versions

- 0.3.5 (latest) — 2025-02-11
- 0.3.4 — 2025-01-24
- 0.3.3 — 2018-06-02
- 0.3.2 — 2014-01-07
- 0.3.1 — 2014-01-07
- 0.1.0 — 2012-09-29

## README

# for-each [![build status][1]][2]

[![browser support][3]][4]

A better forEach.

## Example

Like `Array.prototype.forEach` but works on objects.

```js
var forEach = require("for-each")

forEach({ key: "value" }, function (value, key, object) {
    /* code */
})
```

As a bonus, it's also a perfectly function shim/polyfill for arrays too!

```js
var forEach = require("for-each")

forEach([1, 2, 3], function (value, index, array) {
    /* code */
})
```

## Installation

`npm install for-each`

## MIT Licenced

  [1]: https://secure.travis-ci.org/Raynos/for-each.png
  [2]: http://travis-ci.org/Raynos/for-each
  [3]: https://ci.testling.com/Raynos/for-each.png
  [4]: https://ci.testling.com/Raynos/for-each

---
_Source: https://npm.io/package/for-each · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
