Travis build: 1310
This commit is contained in:
@ -5,9 +5,12 @@ Iterates over all own properties of an object in reverse, running a callback for
|
||||
Use `Object.keys(obj)` to get all the properties of the object, `Array.reverse()` to reverse their order and `Array.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.
|
||||
|
||||
```js
|
||||
const forOwnRight = (obj, fn) => Object.keys(obj).reverse().forEach(key => fn(obj[key],key,obj));
|
||||
const forOwnRight = (obj, fn) =>
|
||||
Object.keys(obj)
|
||||
.reverse()
|
||||
.forEach(key => fn(obj[key], key, obj));
|
||||
```
|
||||
|
||||
```js
|
||||
forOwnRight({foo: 'bar', a: 1}, v => console.log(v)); // 1, 'bar'
|
||||
forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar'
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user