remove duplicates out of an array swift 4 code example
Example 1: javascript removing items looping through array
var colors=["red","green","blue","yellow"];
for (var i = colors.length - 1; i >= 0; i--) {
if (colors[i] === "green" || colors[i] === "blue") {
colors.splice(i, 1);
}
}
Example 2: remove a particular element from array
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");
colors.splice(carIndex, 1);
Example 3: lodash remove multiple items from array
var colors = ["red","blue","green","yellow"];
var removedColors = _.remove(colors, function(c) {
return (c === "green" || c === "yellow");
});