Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

for-each

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
35
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 years ago
SIZE
503 B
Invoke a function for every key within given object or array.
2 contributors
Install for-each as a package?
Copied
npm i @bit/bit.utils.object.for-each
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
forEach({ a: 1, b: 2, c: 3 }, (val, key) => console.log(key, val));
 // => a 1 b 2 c 3
modifieddraft
chevron_left
chevron_right
forEach (
obj:object,
cb:function
)

Invoke a function for every key within given object or array.

Example
forEach({ a: 1, b: 2, c: 3 }, (val, key) => console.log(key, val));
 // => a 1 b 2 c 3
Arguments
obj: object

object or array to iterate

cb: function

callback function to invoke

Test Summary

#forEach() should invoke cb for every key within given object

Pass

#forEach() should invoke cb for every key within given array

Pass