Currently, I am working on JavaScript and encountering an issue with my JSON object:
var obj ={"name" : "objName",
"dynamicList" :[]};
I have been adding items to my list using the following approach:
obj.dynamicList["someStringID"] = {"watever"};
Surprisingly, I recently discovered that it is essential to use a string as an indexer for each item in my list.
However, I am facing a problem when I request obj.dynamicList.length
, as it always returns 0
unless I manually set the correct number. Thus, I was wondering if there is a more efficient way to add items to my list?
Your assistance would be greatly appreciated! Thank you!