This question already has an answer here:
- Find object by id in an array of JavaScript objects 32 answers
- Loop through an array in JavaScript 39 answers
In an example like this, I'm trying to get inside the array of the 'new folder' to take out the keys from the information array that is nested inside the "new folder' array.
let info = [
{
fileName: ‘new folder’,
size: 233423,
information:
{
created: ‘2014-06-06’,
modified: ‘2016-03-04
}
},
{
fileName: ‘untitled’,
size: 554,
information:
{
where: ‘desktop’
}
},
{
fileName: ‘documents’,
size: 743482,
information: ‘created yesterday‘
}
For now I tried
console.log(info[0].information)
It does the trick but I was wondering if there was another way to do it?
I also was trying to get the 'modified' key of the 'new folder' array with
console.log(info[0].information.modified)
which again worked, but I don't know if this would seem as hard coding?