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 -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -