jquery - Remove the element from the array in javascript? -


this question has answer here:

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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

asp.net ajax - Jquery scroll to element just goes to top of page -