I have the following array filter with a callback function:
array.filter(createPredicateFn(expression, comparator));
My call back function is declared as follow:
function createPredicateFn(expression, comparator) {
How can I get the index of the element inside my createPredicateFn?
Edit:
here is my predicate function:
function createPredicateFn(expression, comparator) {
var predicateFn;
if (comparator === true) {
comparator = angular.equals;
} else if (!angular.isFunction(comparator)) {
comparator = function (actual, expected) {
if (angular.isObject(actual) || angular.isObject(expected)) {
// Prevent an object to be considered equal to a string like `'[object'`
return false;
}
actual = angular.lowercase('' + actual);
expected = angular.lowercase('' + expected);
return actual.indexOf(expected) !== -1;
};
}
predicateFn = function (item) {
return deepCompare(item, expression, comparator);
};
}
createPredicateFn