Javascript: extract objects from inside an array of objects, and put them into a new array

blomster

Say I had

var people =[{name:"Jim", address:{number:"21",street:"park lane"}},
{name:"Karen",address:{number:"35", street:"oxford drive"}},
{name:"Bob",address:{number:65, street:"main avenue"}}]

and I wanted to get an array of just the address objects, is there a shorthand way?

I know I could just iterate over the people array and push the addresses onto a new array, but I imagine there must be an easier way.

M. Page

Maybe this:

people.map(function(x){return x.address;});

You are still iterating, but it is more concise.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Make json from array of objects javascript

분류에서Dev

Javascript array of objects undefined

분류에서Dev

How to access attributes of php object inside a array of php objects from javascript

분류에서Dev

JavaScript Objects - I'm having issues accessing an array of objects properties nested multiple levels & combining them together

분류에서Dev

Populating Object array with new Objects

분류에서Dev

JavaScript: Add JSON objects from one array to another array conditionally

분류에서Dev

How to get all values of objects inside array

분류에서Dev

create a new array of objects and merge the objects with same value

분류에서Dev

Array into an array of objects in Java

분류에서Dev

Better way to create objects' array and then deleting them effectively

분류에서Dev

Sorting array of objects based on data in the object, and nesting them

분류에서Dev

Given array of parameters, make array from array of objects

분류에서Dev

javascript iterating array of objects using checkboxes

분류에서Dev

How to remove a simple specific key value pair from all objects inside an array

분류에서Dev

Get object from array with NSDictionary objects

분류에서Dev

how is Array object different from other objects

분류에서Dev

Javascript: Replace everything inside an Array with a new value

분류에서Dev

transform JSON array of objects, create new property from two property values

분류에서Dev

How to get data from inputs and put them in an array using jQuery?

분류에서Dev

How to combined array of objects one to another array using javascript

분류에서Dev

Filter and uniq array of objects

분류에서Dev

creating array of objects

분류에서Dev

Compare objects in an array

분류에서Dev

Changing the css of objects in a array

분류에서Dev

Convert JSON array of objects into nasted json tree usning JavaScript

분류에서Dev

How to click through array of objects and display data in div using javascript

분류에서Dev

Inherited child objects share the same array property in JavaScript?

분류에서Dev

How to access a property in array of objects without looping through all of them in php?

분류에서Dev

React / Spring Boot - how to populate array from list of objects

Related 관련 기사

  1. 1

    Make json from array of objects javascript

  2. 2

    Javascript array of objects undefined

  3. 3

    How to access attributes of php object inside a array of php objects from javascript

  4. 4

    JavaScript Objects - I'm having issues accessing an array of objects properties nested multiple levels & combining them together

  5. 5

    Populating Object array with new Objects

  6. 6

    JavaScript: Add JSON objects from one array to another array conditionally

  7. 7

    How to get all values of objects inside array

  8. 8

    create a new array of objects and merge the objects with same value

  9. 9

    Array into an array of objects in Java

  10. 10

    Better way to create objects' array and then deleting them effectively

  11. 11

    Sorting array of objects based on data in the object, and nesting them

  12. 12

    Given array of parameters, make array from array of objects

  13. 13

    javascript iterating array of objects using checkboxes

  14. 14

    How to remove a simple specific key value pair from all objects inside an array

  15. 15

    Get object from array with NSDictionary objects

  16. 16

    how is Array object different from other objects

  17. 17

    Javascript: Replace everything inside an Array with a new value

  18. 18

    transform JSON array of objects, create new property from two property values

  19. 19

    How to get data from inputs and put them in an array using jQuery?

  20. 20

    How to combined array of objects one to another array using javascript

  21. 21

    Filter and uniq array of objects

  22. 22

    creating array of objects

  23. 23

    Compare objects in an array

  24. 24

    Changing the css of objects in a array

  25. 25

    Convert JSON array of objects into nasted json tree usning JavaScript

  26. 26

    How to click through array of objects and display data in div using javascript

  27. 27

    Inherited child objects share the same array property in JavaScript?

  28. 28

    How to access a property in array of objects without looping through all of them in php?

  29. 29

    React / Spring Boot - how to populate array from list of objects

뜨겁다태그

보관