Array apears as object inside $scope

I have this code example:

$scope.testarray = {
    "a": true,
    "b": true,
    "c":false
};
$scope.test = function () {
    alert($scope.testarray.length);
}

I was expecting to see the alert with "3" but I'm getting a "0" (in some cases - undefined) and I can't find why.

I'm using this for creating a set of checkboxs while the array is needed in order to check the status of them once the form is submitted.

Example: http://jsfiddle.net/dorongol/cwZ6F/

You are using an object instead of an array. Only real arrays keep track of the "length" property automatically. If you want to use an object, you need to handle it yourself (by creating a getLength method in the object, for instance).

For real arrays, this would work, but you have no choice but to use 0-based indexes.

$scope.testarray = [true, true, false];
$scope.test = function () {
    alert($scope.testarray.length);
}

Note this looks like global variables, which is usually a bad idea.

to get the hash length, and reiterate thru them

 $scope.checkboxgetfilters = function () {
    alert(Object.keys($scope.filtergroup1).length);
     var str = '';
       for (var i in $scope.filtergroup1) {
         alert($scope.filtergroup1[i]);
       }
  }

You could use an array of objects if you still want both a name and a status

$scope.testarray = [
    {
     "name":"a",
     "enabled": true
    },
    {
     "name":"b",
     "enabled": true
    },
    {
     "name":"c",
     "enabled": false
    }
];

Best of both worlds!