У меня есть объект, который содержит несколько массивов. Мне нужно знать количество массивов в этом объекте.
Это код, который создает объект карты:
function parseXML(xData, Status){
var map = {}; //init the map
var web = $(xData.responseXML).find("Web");
for (var i = 0; i < web.length; i++) {
//we create a index for our links based on the depth of them by '/'
var m = web[i].attributes['Url'].value.substring(23, web[i].attributes['Url'].value.length).split('/').length;
map[m] = map[m] || []; //make sure we leave alone the old values if there is none init with new array
map[m].push(web[i].attributes['Url'].value); //push new value to node
}
console.log(map);
createNav(map);
}
Я пробовал:
console.log("есть" +map. length+ "уровни на этом сайте"); но я получаю map.length = undefined.
map.length = 0;
for (item in map) {
if (map.hasOwnProperty(item) && map[item] instanceof Array) {
map.length++
}
}