0

I have an object in javascript as below when I print it in console.

 >>recent_projcts
 Array[2]
 0: Object1: Object
     id: 39
     name: "sample1"
 1: Object2: Object
     id: 40
     name: "sample2"

its similar to list of dictionary in python

[
  {'id':39,'name':'sample1'},
  {'id':40,'name':'sample2'}
]

How can I get only the id's in a variable. In general I need to know how to do loop in javascript for list and get required values

2
  • What have you tried so far? Remember, SO isn't a code translation service. Have you really not tried using google? "loop object js" didn't bring anything up? Commented Nov 10, 2016 at 10:39
  • In ES6, recent_projects.map(e => e.id) Commented Nov 10, 2016 at 10:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.