I fill my key value array like this:
/**
* Callback: Gets invoked by the server when the data returns
*
* @param {Object} aObject
*/
function retrieveStringsFromServerCallback(aObject){
for(var i = 0;i < aObject['xml'].strings.appStringsList.length;i++){
var tKey = aObject['xml'].strings.appStringsList[i]["@key"];
var tValue = aObject['xml'].strings.appStringsList[i]['$'];
configManager.addStringElement(tKey,tValue);
}
}
Here is the setter of my object
/**
* @param {string} aKey
* @param {string} aValue
*/
this.addStringElement = function(aKey, aValue){
self.iStringMap[aKey] = aValue;
console.log("LENGTH: "+self.iStringMap.length);
}
I add about 300 key value pairs, according to google chrome inspector, the iStringMap is filled correctly. However the length of the array seems still to be 0. There must be something wrong. Any help much appreciated
You can get the count of object keys using:
Object.keys()returns an array of keys of an object passed as a first parameter. And after that you’re accessing the.lengthof that array.