I have an array, i wan to add one more key value pair at each index.
var ajaxResult = ajaxGet("URL");
if (ajaxResult.length > 0) {
for (var i = 0; i < ajaxResult.length; i++) {
debugger
ajaxResult[i].prototype.push.apply({ "selectedTripLeader": $scope.TripLeaderData[0].Id });
debugger
}
}
I am trying to achieving * selectedTripLeader at each array item present into ajaxResult.* e.g. array[0].push({ "selectedTripLeader": $scope.TripLeaderData[0].Id }) array[1].push({ "selectedTripLeader": $scope.TripLeaderData[0].Id })
i have tried using normal push and prototype.push but it is not working. Solution with for loop or for each loop will be ok