Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to use JavaScript map() method to access nested objects?

//access value by using map
var personsInfo = {
    company: 'sp-coder',
    persons: [{
        id: 1,
        name: 'Adil'
    }, {
        id: 2,
        name: 'Arif'
    }]
};
const getNames = personsInfo.persons.map((data) => data.name);
console.log(getNames);
//Expected Output is [ 'Adil', 'Arif' ]
Comment

PREVIOUS NEXT
Code Example
Javascript :: regex country code 
Javascript :: editor convert jquery code to javascript 
Javascript :: javascript binary tree 
Javascript :: jquery if element has multiple classes 
Javascript :: button click event 
Javascript :: how to define class in javascript 
Javascript :: electron js execute command line 
Javascript :: connect react to backend 
Javascript :: switch 
Javascript :: 206. reverse linked list javascript 
Javascript :: traversing in jquery 
Javascript :: nextjs apollo 
Javascript :: sweetalert2 redirect after ok 
Javascript :: JavaScript (rhino 1.7.9) sample 
Javascript :: search query in javascript 
Javascript :: js how to get n fibonacci number 
Javascript :: regex concatenazione 
Javascript :: react props class based static proptypes 
Javascript :: javascript Arguments Binding 
Javascript :: date methods javascript 
Javascript :: JavaScript Validation API 
Javascript :: jQuery Traversing - Ancestors 
Javascript :: query middleware in express 
Javascript :: get biggest element in array javascript 
Javascript :: phaser rotate around 
Javascript :: get lat long react native 
Javascript :: scan token deploy js 
Javascript :: javascript concat two htmlcollection 
Javascript :: how to choose a weighted random array element in javascript 
Javascript :: javascript map foreach 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =