I have this algorithme issue, I would like to check if an Object is already present in my Array **before adding it**. 

I tried many different approaches (indexOf, filter...), and my last attempt is with an angular.foreach. 

The problem is my $scope.newJoin remains always empty. I understood why, it's because the if is never read, because of the 0 size of my $scope.newJoin, but I don't know how to figure this out...

---

**$scope.newJoinTMP** is composed by : 6 Objects, within each a **timePosted** attribute (used for compare these different array Objects).

**$scope.newJoin** is an empty Array. I want to fill it with the Objects inside **$scope.newJoinTMP** but with the certainty to have **once** each Objects, and not twice the same ($scope.newJoinTMP can have duplicates Objects inside, but $scope.newJoin mustn't).

```js
                    angular.forEach($scope.newJoinTMP, function(item) 
                    { 

                        angular.forEach($scope.newJoin, function(item2)
                        {
                            if (item.timePosted === item2.timePosted) 
                            {
                                //snap.val().splice(snap.val().pop(item));
                                console.log("pop");
                            }
                            else
                            {
                                $scope.newJoin.push(item);
                                console.log("newJoin :", $scope.newJoin);
                            }
                        });
                    });
```