'Access object properties

 {
    id: '1',
    type: "folder",
    name: "new Folder 1",
    files: [
        { id: '1.1', type: "file", name: "file 1" },
        { id: '1.2', type: "file", name: "file 2" },
        { id: '1.3', type: "file", name: "file 3" },
    ]
},
{
    id: '2',
    type: "folder",
    name: "new Folder 2",
    files: [
        { id: '2.1', type: "file", name: "file 4" },
        {
            id: '2.2',
            type: "folder",
            name: "new Folder 3",
            files: [
                { id: '2.2.1', type: "file", name: "file 7" },
            ]
        },
        { id: '2.3', type: "file", name: "file 5" },
        { id: '2.4', type: "file", name: "file 6" },
    ]
},

i want to access and pushing some elements to this kinda of data structure like pushing some data or crating folders under list[1][1][2] or to list[1] but i dont know the number of the iterations it can be 1 or more its variable



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source