check if property value exist before push item

Viewed 1949

Below is my sample code that pushes into VacanciesWithSavedSearches array by checking if the item does not already exist.

 if ($scope.VacanciesWithSavedSearches.indexOf(value) == -1) {

            $scope.VacanciesWithSavedSearches.push({
                type: "Saved Searches",
                title: value.title,
                value: value.id
            });
        }

How do I change the above by replacing indexOf with the actually property value, e.g Add item to the list VacanciesWithSavedSearches if the list do not contain another item.id=123

3 Answers
Related