i trying remove specific array array using first items name.
for example:
myarray = [["human", "mammal"], ["shark", "fish"]]; i need use first item in array remove array containing it.
let's want remove array containing ['human', 'mammal']. how remove using first value 'human' in array?
before had 2 dimensional array able remove specific item array using code:
var removeitem = productarray.indexof(valuelabel); if (removeitem != -1) { productarray.splice(removeitem, 1); } obviously method not work anymore.
jquery not required task. array.prototype.filter() able solve problem:
var myarray = [["human", "mammal"], ["shark", "fish"]]; var exclude = "human"; var filtered = myarray.filter(function(item) { return item[0] !== exclude; }); console.log(filtered); // [["shark", "fish"]]
Comments
Post a Comment