Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:09:55+00:00 2026-06-04T03:09:55+00:00

I am currently using the jQuery $.grep() method to filter an array by a

  • 0

I am currently using the jQuery $.grep() method to filter an array by a value passed to the method like so:

var filteredArray = $.grep(arr, function (n, i) {
    return (n.type === type);
}, true);

So the array is an array of objects that have a type property and if that property is equal to the type passed to it then filter out the other objects and produce a new array from the result.

How do i extend this to accept multiple types of filters?

So if i pass an array of filters that can be a minimum length of 1 and nay maximum.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:09:57+00:00Added an answer on June 4, 2026 at 3:09 am
    var types = [1, 2]; // example of types...
    
    var filteredArray = $.grep(arr, function(element) {
        return $.inArray(element.type, types) >= 0;
    });
    
    console.log(filteredArray);​
    

    Live DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using jQuery and would like some help on iterating through all checked
I'm currently using jQuery to return some JSON results. Once these results are returned,
I am currently using jquery slideonlyone function. I am having problems implementing an expanding/collapsing
I am currently using jquery function(below) to display a block on click of a
I'm using jQuery's AJAX function, like so: $.ajax ({ url : /note, async :
I am currently using jQuery .click() method to update 15 text fields with simple
I am currently using jQuery's resize function, but because of what I adjust on
I'm currently using jQuery to make a div clickable and in this div I
I'm currently using JQuery to assign colors to containers. In Chrome and IE, when
I'm currently using jQuery Cookies plugin, and depending on which side of the page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.