There is also a bug x = 3
'=' is assignment '==' is equality without type comparison.
$scope.myArray = [];
Object.keys($scope.obj).forEach(function(key) {
var curNode = $scope.obj[key];
if ( curNode ) {
if ( x == 3 ) {
$scope.myArray.push(curNode);
myFunction({
//do something before the callback,
});
}
}
});
$scope.myCallback = function ( arry ) {
//do something ONCE with arry
}
$scope.myCalback( $scope.myArray ) ;