Skip to content
Advertisement

Tag: nested-documents

Access dynamic nested key in JS object

I have an array like [‘animals’, ‘cats’, ‘cute’, ‘fast’, ‘small’, …], and want to access nested keys of the object like Usually I would write object[‘animals’][‘cats’][‘cute’][‘fast’][‘small’].. The problem is that keys and the number of levels are dynamic (so I can get objects with 2 nested levels or 50), so I have no idea how it can be done Thanks

Advertisement