Get property of object when property name is variable in JavaScript

Given an object, say like this: const data = { “menu”:{ “id”:”file”, “value”:”File”, “popup”:{ “menuitem”:[ { “value”:”New”, “onclick”:”CreateNewDoc()” }, { “value”:”Open”, “onclick”:”OpenDoc()” } ] } } } I want to get one of the nested properties of the object, say popup, but that could be the name of any type of Web widget – that’s…

Details