Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

added 55 characters in body
Source Link
Paaarth
  • 4.5k
  • 3
  • 27
  • 39

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
  'age': 1 
 }
}; 
_.mapValues(users, function(o) { return o.age; });
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
// The `_.property` iteratee shorthand.
console.log(_.mapValues(users, 'age')); // returns age property & value 
console.log(_.mapValues(users, 'user')); // returns user property & value 
console.log(_.mapValues(users)); // returns all objects 
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
 
 _.mapValues(users, function(o) { return o.age; });
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
// The `_.property` iteratee shorthand.
console.log(_.mapValues(users, 'age')); // returns age property & value 
console.log(_.mapValues(users, 'user')); // returns user property & value 
console.log(_.mapValues(users)); // returns all objects 
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 
 },
 'pebbles': { 'user': 'pebbles',
  'age': 1 
 }
}; 
_.mapValues(users, function(o) { return o.age; });
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
// The `_.property` iteratee shorthand.
console.log(_.mapValues(users, 'age')); // returns age property & value 
console.log(_.mapValues(users, 'user')); // returns user property & value 
console.log(_.mapValues(users)); // returns all objects 
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

deleted 7 characters in body
Source Link
Paaarth
  • 4.5k
  • 3
  • 27
  • 39

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
 
 _.mapValues(users, function(o) { return o.age; });
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
 // The `_.property` iteratee shorthand.
 console.log(_.mapValues(users, 'age')); // returns age property & value 
 // console.log(_.mapValues(users, 'user')); // returns user property & value 
 // console.log(_.mapValues(users)); // returns all objects 
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
 
 _.mapValues(users, function(o) { return o.age; });
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
 // The `_.property` iteratee shorthand.
 console.log(_.mapValues(users, 'age')); // returns age property & value 
 // console.log(_.mapValues(users, 'user')); // returns user property & value 
 // console.log(_.mapValues(users)); // returns all objects 
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
 
 _.mapValues(users, function(o) { return o.age; });
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
 // The `_.property` iteratee shorthand.
 console.log(_.mapValues(users, 'age')); // returns age property & value 
 console.log(_.mapValues(users, 'user')); // returns user property & value 
 console.log(_.mapValues(users)); // returns all objects 
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

Source Link
Paaarth
  • 4.5k
  • 3
  • 27
  • 39

You can try using lodash- A modern JavaScript utility library delivering modularity, performance & extras js to fast object iterate:-

 var users = {
 'fred':  { 'user': 'fred',  'age': 40 },
 'pebbles': { 'user': 'pebbles', 'age': 1 }
 };
 
 _.mapValues(users, function(o) { return o.age; });
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
 // The `_.property` iteratee shorthand.
 console.log(_.mapValues(users, 'age')); // returns age property & value 
 // console.log(_.mapValues(users, 'user')); // returns user property & value 
 // console.log(_.mapValues(users)); // returns all objects 
 // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.2/lodash.js"></script>

lang-js

AltStyle によって変換されたページ (->オリジナル) /