You can use the function filter(fc), whose parameter fc must be a function that takes as argument each element of the array (in other words, a function fc(el)); in your case, each element of the original array is others array.The function fc(el) has the purpose of saying whether the element should be maintained (return value equivalent to true), or else excluded from the resulting array of the function filter (conductor value false).Still, the function fc(el) can be anonymous, as in the example below:var array = [
["755", "20", "E", "274"],
["756", "20", "E", "274"],
["455", "30", "E", "159"],
["757", "20", "E", "274"],
["456", "30", "E", "159"],
["269", "20", "E", "160"]
];
// Atenção à função "filter(fc)", cuja função-parâmetro "fc", nesse caso, é anônima:
var array_filtrado = array.filter(function(arr){
// Para cada array filho ("arr"), verifica se ele é igual a ["757", "20", "E", "274"]:
var igual = (arr[0] == "757") &&
(arr[1] == "20" ) &&
(arr[2] == "E" ) &&
(arr[3] == "274") ;
// Se for igual, exclui do resultado (return false):
return !igual;
});
console.log(array_filtrado); // Mostra o resultado no console do browser.
Obviously, we can always improve a source code, especially if some kind of simplification can be used. So if we assume that the array elements are always strings (e.g.), it is safe to reduce the condition of equal arrays to a simple a.toString() == b.toString():var array = [
["755", "20", "E", "274"],
["756", "20", "E", "274"],
["455", "30", "E", "159"],
["757", "20", "E", "274"],
["456", "30", "E", "159"],
["269", "20", "E", "160"]
];
var array_filtrado = array.filter(function(arr){
var igual = arr.toString() == ["757","20","E","274"].toString();
return !igual;
});
console.log(array_filtrado);What can be compressed even more (thing I did not, for didactic purposes).To finish, chaining filters is simple (please apply a new filter() about the result of filter() previous), and can be done through two syntax:// Sintaxe 01:
var array_filtrado = array.filter(...);
array_filtrado = array_filtrado.filter(...);
array_filtrado = array_filtrado.filter(...);
// Pode ser reduzido para: (Sintaxe 02)
var array_filtrado = array.filter(...).filter(...).filter(...) ///...
This, however, is too costly for your particular case, in which we always want to apply the same filtering criterion: to exclude the elements that coincide with other certain elements. Therefore, I suggest you create an array of elements to be deleted:var array = [
["755", "20", "E", "274"],
["756", "20", "E", "274"],
["455", "30", "E", "159"],
["757", "20", "E", "274"],
["456", "30", "E", "159"],
["269", "20", "E", "160"]
];
var excluir = [
["757", "20", "E", "274"],
["269", "20", "E", "160"]
];
var array_filtrado = array.filter(function(arr){
var igual = false;
for(var i = 0; i < excluir.length; i++){
if(arr.toString() == excluir[i].toString()) igual = true;
}
return !igual;
});
console.log(array_filtrado);