Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

accessing objects inside array

// Array of object
var persons = [
  {
    name: "shubham",
    age: 22,
    comments: ["Good", "Awesome"]
  },
  {
    name: "Ankit",
    age: 24,
    comments: ["Fine", "Decent"]
  },
  {
    name: "Arvind",
    age: 26,
    comments: ["Awesome", "Handsome"]
  },
  {
    name: "Ashwani",
    age: 28,
    comments: ["Very Good", "Lovely"]
  }
];

var data = persons.map(person => {
  console.log(person.name);
  console.log(person.age);
  person.comments.map((comment, index) => console.log(index + " " + comment));
});
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: next js notifications 
Javascript :: Prevent default event behavior 
Javascript :: javascript null check 
Javascript :: react export 
Javascript :: how to exit node 
Javascript :: json value types 
Javascript :: Get the url and parse or url.parse deprecated solved 
Javascript :: The anchorEl prop provided to the component is invalid. 
Javascript :: clearing setinterval 
Javascript :: Find the index of an item in the Array 
Javascript :: select the first elemnt have class in jquery 
Javascript :: js var vs let 
Javascript :: how to remove selected characters from a string in javascript 
Javascript :: javascript submit form programmatically 
Javascript :: javascript create an array 
Javascript :: get user input node js console 
Javascript :: post to /wp-json/wp/v2/media 
Javascript :: global variable vuejs 
Javascript :: how to create react app 
Javascript :: react native asign width to image 
Javascript :: javascript reduce sum 
Javascript :: disable URL encoder javascript 
Javascript :: count in string javascript 
Javascript :: javascript dataset 
Javascript :: javascript wrap object in array 
Javascript :: automatically click button javascript on setinterval 
Javascript :: js detect user mobile 
Javascript :: catch errors async await javascript 
Javascript :: npm hook form 
Javascript :: how to send the mail using node with template 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =