jquery - Remove the element from the array in javascript? -
this question has answer here:
- remove duplicates javascript array 53 answers
var arr = ["cat", "dog", "bear", "cat", "bird", "dog", "dog","cat"]; arr.remove("cat", "dog"); console.log(arr);
i want delete string "cat" , "dog" want print them 1 time in result. can me?
use filter function.
var arr = ["cat", "dog", "bear", "cat", "bird", "dog", "dog","cat"]; arr = arr.filter(function(item, pos) { return arr.indexof(item) == pos; }); console.log(arr);
Comments
Post a Comment