Javascript 获取数组大小(以角度为单位)

Javascript 获取数组大小(以角度为单位),javascript,angularjs,Javascript,Angularjs,我试图得到一个数组的大小,但每次控制台说我未定义,不知道为什么 .success(function (data) { console.log('Random-Suffix:' + suffix); $scope.builds = new X2JS().xml_str2json(data); var size = $scope.builds.length; console.log('Size: '

我试图得到一个数组的大小,但每次控制台说我未定义,不知道为什么

.success(function (data) {
            console.log('Random-Suffix:' + suffix);
            $scope.builds = new X2JS().xml_str2json(data);

            var size  = $scope.builds.length;
            console.log('Size: ' + size);



            $timeout(function () {
                $scope.exampleLiveDataChange();
            }, 3000);
        })
我在报纸上读到:

如果您这样做:

test.length;
test.two.length;
你会得到:

undefined
如果您这样做:

test.length;
test.two.length;
然后你会得到:

3

console.log($scope.builds)
的输出是什么?试试
console.log(typeof($scope.builds))
你很可能会看到
$scope.builds
不是数组!然后您可能需要输出它并在其中查找您的数组;是的,你说得对,谢谢。你知道有没有办法得到物体内部数组的大小?是的,很简单。对象的结构是什么?