I have Angular JS code with filter:
.filter('filterSelectOptionAllowed', function () {
            var allowed = {1: [0, 1, 2, 3, 4], 2: [0, 1, 2, 3, 4], 3: [1, 2, 3, 4]};
            var d = {};
            return function (num, account) {
                angular.forEach(num, function (item, key) {
                    var arrElem = allowed[account];
                    if (arrElem.indexOf(key) > -1) {
                        d[key] = item;
                    }
                });
                return d;
            };
        });
acount is 3.
So, I check if key exists in array arrElem I add this element to object d.
Why do I get empty object d in return?
I tried too:
return function (num, account) {
                var arrElem = allowed[account];
                angular.forEach(num, function (item, key) {
                    if ($.inArray(parseInt(key), arrElem ) > -1 ){
                        d[key] = item;
                    }
                });
                return d;
            };
 
    