Remove Multiple Values from Array using JQuery

Remove Multiple Values from Array using JQuery
So let’s see bellow simple example of jquery remove multiple values from an array.

we will use Array.prototype.remove, grep() and inArray() for removing multiple values from array in jquery. checkout below code example. you can use easily with your JQuery Array.

you can just see below example it’s done. you can easily use with your jquery array.

<!DOCTYPE html>
<html>
<head>
   <title>Remove Multiple Values from Array Using Jquery</title>
   <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
  <h2>Remove Multiple Values from Array Using Jquery</h2>
<script type="text/javascript">
    var names = [ "Siddharth", "Yash","Saurabh" ];
  
    Array.prototype.remove = function(){
        var args = Array.apply(null, arguments); 
   
        return $.grep(this, function(value) {
           return $.inArray(value, args) < 0;
        });
    }
  
    userName = names.remove("Siddharth", "Yash");
  
    console.log(userName);
</script>
  
</body>
</html>

<!-- 
Output:

["Saurabh"]
-->
Leave a Comment