I am making some common function where in I pass the array, name of field from array, value of field in array and return field name to return value as below
function arrayFilter(_array, findField, value, returnField) {
var temp = "_array[i]." + findField;
var retValue = "";
for (var i = 0; i < _array.length; i++) {
if (eval(temp) == value) {
return eval("_array[i]." + returnField);
}
}
}
But when I read on Internet I found that eval is not good, it can have string injection attack.
So somebody help on above.