What is the difference between splice
and slice
?
$scope.participantForms.splice(index, 1);
$scope.participantForms.slice(index, 1);
Here is a simple trick to remember the difference between slice
vs splice
var a=['j','u','r','g','e','n'];
// array.slice(startIndex, endIndex)
a.slice(2,3);
// => ["r"]
//array.splice(startIndex, deleteCount)
a.splice(2,3);
// => ["r","g","e"]
Trick to remember:
Think of "spl" (first 3 letters of splice)
as short for "specifiy length", that the second argument should be a length not an index