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

python - PyInstaller UAC not working in onefile mode -

python - RuntimeError: can't re-enter readline -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -