One option would be to reduce the keys():

var o = { 
    a: {value:1}, 
    b: {value:2}, 
    c: {value:3} 
};

Object.keys(o).reduce(function (previous, key) {
    return previous + o[key].value;
}, 0);

With this, you'll want to specify an initial value or the 1st round will be 'a' + 2.

If you want the result as an Object ({ value: ... }), you'll have to initialize and return the object each time:

Object.keys(o).reduce(function (previous, key) {
    previous.value += o[key].value;
    return previous;
}, { value: 0 });
Answer from Jonathan Lonowski on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › reduce
Array.prototype.reduce() - JavaScript - MDN Web Docs
July 20, 2025 - The reduce() method of Array instances executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
Discussions

How to reduce array of objects to array
Greetings, Say for example i dont wish to use a for loop or forEach, I also dont wish to map and then do another pass to clear undefined values. how would I say convert an array of objects into different array, want this… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
13
0
June 12, 2022
Can anyone explain to me easily .reduce in js !
Reduce is the most low-level of these array iteration methods, so it has the widest variety of potential uses and requires the most complex boiler plate to write. That makes it hard to sum up in a concise way. You often hear people describe reduce as "reducing an array to a single value" or something like that, but I find that definition both hard to understand and kind of inaccurate (reduce can produce another array!). So I don't really try to sum up reduce. I just think of it purely in mechanical terms. Imagine we wrote our own version. function reduce(items, iteratee, initial) { let accumulator = initial; for (const item of items) { accumulator = iteratee(accumulator, item); } return accumulator; } We can then use this reduce just like the built in one. function add(x, y) { return x + y; } const nums = [1, 2, 3]; const sum = reduce(nums, add, 0); console.log(sum); // 6 So what does reduce do? It calls a function on each item in an array, passing along both the result of the previous call and the item itself, before finally returning the result of the final call. It defies any less mechanical definition because it is a fiddly mechanical function with only fiddly technical use cases. EDIT: clarified wording More on reddit.com
🌐 r/learnjavascript
21
15
August 2, 2022
🌐
W3Schools
w3schools.com › jsref › jsref_reduce.asp
JavaScript Array reduce() Method
Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array BigInt64Array BigUint64Array Float16Array Float32Array Float64Array JS Typed Reference · at() byteLength byteOffset bytesPerElement copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() forEach() from() includes() indexOf() join() keys() lastIndexOf() length map() name of() reduce() reduceRight() reverse() set() slice() some() sort() subarray() toLocaleString() toReversed() toSorted() toString() values() with() Temporal Objects New Temporal.Duration ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Iterator › reduce
Iterator.prototype.reduce() - JavaScript - MDN Web Docs
July 10, 2025 - The reduce() method of Iterator instances is similar to Array.prototype.reduce: it executes a user-supplied "reducer" callback function on each element produced by the iterator, passing in the return value from the calculation on the preceding element. The final result of running the reducer ...
🌐
Redbitdev
redbitdev.com › post › using-array-reduce-with-objects
Using Array.reduce With Objects
September 21, 2021 - Example 4 reduces the keys from the 'person' object into a new object that only contains the properties whose keys are included in the 'allowedProperties' array. If you add a new property to the 'person' object it will not appear in the result unless you also add the property name to the allowed properties. ... -- CODE language-js -- // Copy an object, excluding disallowed properties: const person = { firstName: 'Orpheus', lastName: 'De Jong', phone: '+1 123-456-7890', email: 'odj@email.tld', }; const disallowedProperties = ['phone', 'email']; const allKeys = Object.keys(person); const result = allKeys.reduce((next, key) => { if (!disallowedProperties.includes(key)) { return { ...next, [key]: person[key] }; } else { return next; } }, {}); // result: // { firstName: 'Orpheus', lastName: 'De Jong' }
🌐
freeCodeCamp
freecodecamp.org › news › javascript-reduce-method-code-examples
How JavaScript's Reduce Method Works – Explained with Code Examples
February 19, 2024 - Comparison: Both approaches achieve the same result, but reduce() offers a more concise and functional way to find the maximum and minimum values. It leverages the accumulator concept to directly compare and update the values within the callback function. Scenario: You have an array of students and want to group them by their subjects into a single object.
🌐
The New Stack
thenewstack.io › home › javascript: build objects and eliminate looping with reduce()
JavaScript: Build Objects and Eliminate Looping with Reduce() - The New Stack
September 3, 2022 - JavaScript reduce() is great when it comes to chaining higher order functions and abstracting away the looping process.
Find elsewhere
🌐
DEV Community
dev.to › _bigblind › quick-tip-transform-an-array-into-an-object-using-reduce-2gh6
Quick Tip: Transform an Array into an Object using .reduce() - DEV Community
February 18, 2019 - And you'd like to get an object with categories as keys, mapping to the article id's with that category, like this: ... You can use our friend Array.prototype.reduce for this.
🌐
DigitalOcean
digitalocean.com › community › tutorials › js-finally-understand-reduce
The JavaScript Reduce Method Explained | DigitalOcean
September 4, 2020 - So with the new Pokemon game coming out, let’s pretend we have a server that sends us an array of Pokemon objects like so: const pokemon = [ { name: "charmander", type: "fire" }, { name: "squirtle", type: "water" }, { name: "bulbasaur", type: "grass" } ] ... const pokemonModified = { charmander: { type: "fire" }, squirtle: { type: "water" }, bulbasaur: { type: "grass" } }; To get to that desired output we do the following: const getMapFromArray = data => data.reduce((acc, item) => { // add object key to our object i.e.
🌐
Alexandracaulea
alexandracaulea.com › snippets › javascript-reduce-to-object
Using the reduce() method to build JavaScript objects
July 14, 2025 - const arrays = [ ['name', 'Debbie'], ['age', 20], ['city', 'Houston'] ]; const obj = arrays.reduce((acc, [key, value]) => { acc[key] = value; return acc; }, {}); console.log(obj); // Output: { name: 'Debbie', age: 20, city: 'Houston' } If we need to group an array of objects by a specific key:
🌐
DEV Community
dev.to › sanspanic › the-javascript-reduce-method-3j8l
The JavaScript Reduce Method - DEV Community
July 23, 2021 - The initial value is an object with two properties, goodClimateBehaviours and badClimateBehaviours. This is our first accumulator. The callback reducer function iterates over the array of objects. Each time, it checks whether the current object has greenPoints greater than 0.
🌐
Stephan Miller
stephanmiller.com › javascript-reduce
JavaScript Reduce - A Complete Guide to the Only JS Array Function You Really Need — Stephan Miller
January 11, 2024 - JavaScript reduce is a higher order JavaScript function used for manipulating data that reduces an array to a single value. But what this definition doesn’t tell you is that this “single value” can be anything: number, string, array, or object.
🌐
Amit Merchant
amitmerchant.com › reduce-array-of-objects-to-an-object-in-javascript
Reduce array of objects to an object in JavaScript
May 17, 2022 - As you can tell, by using the Array.reduce() method, we can reduce the array to an object by initializing the reducer using an empty object ({}) as the second argument of Array.reduce().
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › TypedArray › reduce
TypedArray.prototype.reduce() - JavaScript - MDN Web Docs
July 10, 2025 - The reduce() method of TypedArray instances executes a user-supplied "reducer" callback function on each element of the typed array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the typed ...
🌐
GitHub
github.com › jonschlinkert › object.reduce
GitHub - jonschlinkert/object.reduce: Reduces an object to a value that is the accumulated result of running each property in the object through a callback. JavaScript/node.js utility. · GitHub
Reduces an object to a value that is the accumulated result of running each property in the object through a callback. JavaScript/node.js utility. - jonschlinkert/object.reduce
Starred by 12 users
Forked by 3 users
Languages   JavaScript
🌐
freeCodeCamp
freecodecamp.org › news › reduce-f47a7da511a9
A Guide To The Reduce Method In Javascript​
February 11, 2017 - We do this by pointing amount.c for each object in the array. We then use a forEach loop to push every value in the nested array into out total. const colors = data.reduce((total, amount) => { amount.c.forEach( color => { total.push(color); }) return total; }, []) colors //['blue','green','green','black','orange','blue','green','red']
🌐
The Code Barbarian
thecodebarbarian.com › javascript-reduce-in-5-examples.html
Understand JavaScript Reduce With 5 Examples | www.thecodebarbarian.com
April 28, 2020 - Write Your Own Node.js Promise ... JavaScript arrays executes a "reducer" function on every element of the array in order, passing the return value from the previous reducer call to the next reducer call....
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
How to reduce array of objects to array - JavaScript
June 12, 2022 - Greetings, Say for example i dont wish to use a for loop or forEach, I also dont wish to map and then do another pass to clear undefined values. how would I say convert an array of objects into different array, want this input: [ {a:1}, {name: 'Jane'}, {}, {b:2}, {name: 'Smith'}, {name: 'Fatima'}, ] to output e.g. : ['Jane', 'Smith', 'Fatima'] Can it be done using reduce?
🌐
Reddit
reddit.com › r/learnjavascript › can anyone explain to me easily .reduce in js !
r/learnjavascript on Reddit: Can anyone explain to me easily .reduce in js !
August 2, 2022 -

I own searched online but I do not understand‏‏‎‏‏‎‏‏‎‏‏‎­things like accumalator or reducer, I understand .map and .filter but not .reduce. If you could an analogy would be appreciated.

Top answer
1 of 5
17
Reduce is the most low-level of these array iteration methods, so it has the widest variety of potential uses and requires the most complex boiler plate to write. That makes it hard to sum up in a concise way. You often hear people describe reduce as "reducing an array to a single value" or something like that, but I find that definition both hard to understand and kind of inaccurate (reduce can produce another array!). So I don't really try to sum up reduce. I just think of it purely in mechanical terms. Imagine we wrote our own version. function reduce(items, iteratee, initial) { let accumulator = initial; for (const item of items) { accumulator = iteratee(accumulator, item); } return accumulator; } We can then use this reduce just like the built in one. function add(x, y) { return x + y; } const nums = [1, 2, 3]; const sum = reduce(nums, add, 0); console.log(sum); // 6 So what does reduce do? It calls a function on each item in an array, passing along both the result of the previous call and the item itself, before finally returning the result of the final call. It defies any less mechanical definition because it is a fiddly mechanical function with only fiddly technical use cases. EDIT: clarified wording
2 of 5
3
you use .map() to create a new array of the same length as the input array you use .filter() to create a new array containing a subset of the input array you use .reduce() to create something entirely new using an array as an input For example, if we have const lovers = ["mindy", "jed", "jerry"]; const sentence = lovers.reduce((phrase, name) => `${name} loves ${phrase}`); console.log(sentence); // jerry loves jed loves mindy We have transformed an array into a string! I just pulled this monkey-island-esque example out my ass, but you get the gist; use .reduce() when you wanna take an array of things, and generate something entirely new using them.
🌐
Medium
vmarchesin.medium.com › using-array-prototype-reduce-in-objects-using-javascript-dfcdae538fc8
Using Array.prototype.reduce to form objects using JavaScript | by Vinicius Marchesin Araujo | Medium
October 19, 2018 - There’s a bunch of ways to approach this problem, but let keep this simple for the sake of the demonstration. As we know the Array.prototype.reduce is a handy method for reducing datasets into meaningful values. One thing that isn’t obvious is that you can reduce arrays to objects as well, not just numbers.