0

Ok, I have seen a couple closely related posts, but they don't seem to address my problem. Or at least not clearly enough for me.

I am receiving an object that is passed to me with no data dictionary included. I know it is a multidimensional array, possibly including more arrays as a dimension.

I know that some of the elements have names and I would like to get the rest of them so I can make sure I am not creating code for something that already exists.

Example:

the object passed to me in javascript and known elements:

objInfo.id      = just an integer
objInfo.name    = just a sting
objInfo.lists[] = another array of information
objInfo.DateTime = obvious
objInfo.?
objInfo.?[]

My question: is there a way to loop thru this object and return the name, if any, of the other elements that I know are there but don't know what they are? And then loop thru any elements that are also arrays for their names if any?

Monkey Wrench
  • 31
  • 1
  • 4
  • 1
    You may want to use [`Object.keys`](//mdn.io/object.keys) – Ulysse BN Aug 15 '17 at 16:04
  • You can also use `for (var key in obj) ` to iterate through the object and get the keys. If that's the only thing you want. – Anurag Singh Bisht Aug 15 '17 at 16:06
  • That was excellent, thanks. Next problem: I built a function for (var prop in objObject) { console.log(`objObject.${prop} = ${objObject[prop]}`); } and received this: objObject.6 = [object Object] – Monkey Wrench Aug 15 '17 at 16:36

0 Answers0