You could use array's filter() function:

function filter_dates(event) {
    return event.date == "22-02-2016";
}

var filtered = events.filter(filter_dates);

The filter_dates() method can be standalone as in this example to be reused, or it could be inlined as an anonymous method - totally your choice =]

A quick / easy alternative is just a straightforward loop:

var filtered = [];
for (var i = 0; i < events.length; i++) {
    if (events[i].date == "22-02-2016") {
        filtered.push(events[i]);
    }
}
Answer from newfurniturey on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › filter
Array.prototype.filter() - JavaScript | MDN
The filter() method of Array instances ... console.log(result); // Expected output: Array ["exuberant", "destruction", "present"] ... A function to execute for each element in the array....
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-filter-array-of-objects-based-on-property
Filter an Array of Objects based on a property - JavaScript | bobbyhadz
Use the Array.filter() method to iterate over the array. On each iteration, check if the object's property points to the specified value.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › filter-array-of-objects
Filter an Array of Objects in JavaScript - Mastering JS
const characters = [ { name: 'James T. Kirk', series: ['Star Trek'] }, { name: 'Spock', series: ['Star Trek', 'Star Trek: The Next Generation'] }, { name: 'Jean-Luc Picard', series: ['Star Trek: The Next Generation'] }, { name: 'Worf', series: ['Star Trek: The Next Generation', 'Star Trek: Deep Space Nine'] } ]; const tngCharacters = characters.filter(character => { return character.series.includes('Star Trek: The Next Generation'); }); Did you find this tutorial useful? Say thanks by starring our repo on GitHub!
🌐
Scott Spence
scottspence.com › home › posts › reduce and filter javascript object on property
Reduce and Filter JavaScript Object on Property - Scott Spence
January 25, 2022 - const products = items .reduce((acc, item) => { if (!acc[item.productId]) { acc[item] = item } acc[item.productId] = item return acc }, []) .filter(item => item !== null) After running my approach past Leigh, he had a much simpler solution! He had a small suggestion on the final code… the initial value should probably be an object {} so that I can check if the productId exists inside of that object.
Top answer
1 of 16
1005

You can use the Array.prototype.filter method:

var newArray = homes.filter(function (el) {
  return el.price <= 1000 &&
         el.sqft >= 500 &&
         el.num_of_beds >=2 &&
         el.num_of_baths >= 2.5;
});

Live Example:

var obj = {
    'homes': [{
            "home_id": "1",
            "price": "925",
            "sqft": "1100",
            "num_of_beds": "2",
            "num_of_baths": "2.0",
        }, {
            "home_id": "2",
            "price": "1425",
            "sqft": "1900",
            "num_of_beds": "4",
            "num_of_baths": "2.5",
        },
        // ... (more homes) ...     
    ]
};
// (Note that because `price` and such are given as strings in your object,
// the below relies on the fact that <= and >= with a string and number
// will coerce the string to a number before comparing.)
var newArray = obj.homes.filter(function (el) {
  return el.price <= 1000 &&
         el.sqft >= 500 &&
         el.num_of_beds >= 2 &&
         el.num_of_baths >= 1.5; // Changed this so a home would match
});
console.log(newArray);

This method is part of the new ECMAScript 5th Edition standard, and can be found on almost all modern browsers.

For IE, you can include the following method for compatibility:

if (!Array.prototype.filter) {
  Array.prototype.filter = function(fun /*, thisp*/) {
    var len = this.length >>> 0;
    if (typeof fun != "function")
      throw new TypeError();

    var res = [];
    var thisp = arguments[1];
    for (var i = 0; i < len; i++) {
      if (i in this) {
        var val = this[i];
        if (fun.call(thisp, val, i, this))
          res.push(val);
      }
    }
    return res;
  };
}
2 of 16
66

I'm surprised no one has posted the one-line response:

const filteredHomes = json.homes.filter(x => x.price <= 1000 && x.sqft >= 500 && x.num_of_beds >=2 && x.num_of_baths >= 2.5);

...and just so you can read it easier:

const filteredHomes = json.homes.filter( x => 
  x.price <= 1000 && 
  x.sqft >= 500 && 
  x.num_of_beds >=2 && 
  x.num_of_baths >= 2.5
);
🌐
EnableGeek
enablegeek.com › home › javascript filter array of objects by property
JavaScript Filter Array of Objects by Property - EnableGeek
March 25, 2024 - We subtract the value of “b.property” from “a.property” to sort the array in ascending order based on the “property” property. Filtering an Array of Objects: To filter an array of objects, we can use the Array.filter() method.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-filter-an-array-of-objects-based-on-multiple-properties-in-javascript
How to Filter an Array of Objects Based on Multiple Properties in JavaScript ? - GeeksforGeeks
August 5, 2025 - ... The filter() method is a built-in array method in JavaScript that creates a new array with elements that pass the provided function's test. Example: This example shows the filter of an array by using the filter() method in JavaScript.
Find elsewhere
🌐
Reddit
reddit.com › r/javascripttips › how to filter array of objects by value in javascript
r/JavaScriptTips on Reddit: How to Filter Array of Objects by Value in JavaScript
April 14, 2023 -

If you're working with arrays of objects in JavaScript, you may find yourself needing to filter the array based on a specific value. Luckily, JavaScript provides us with a built-in method to do just that: Array.filter() . In this article, we'll explore how to to filter an array of objects by value.

Let's say we have an array of objects representing different people, with properties like "name", "age", and "occupation". We want to filter this array to only include people who are over the age of 30. Here's how we could do it:

const people = [
  { name: "Alice", age: 25, occupation: "Engineer" },
  { name: "Bob", age: 35, occupation: "Teacher" },
  { name: "Charlie", age: 42, occupation: "Doctor" },
  { name: "Dave", age: 28, occupation: "Writer" },
];

const filteredPeople = people.filter((person) => person.age > 30);

console.log(filteredPeople);
// Output: [{ name: "Bob", age: 35, occupation: "Teacher" }, { name: "Charlie", age: 42, occupation: "Doctor" }]

Here, we're using the filter() method on the people array, and passing in a function as an argument. This function takes each object in the array as its argument (which we've named person), and returns a boolean value indicating whether that object should be included in the filtered array.

In this case, we're using a simple comparison to check if the person's age is greater than 30. If it is, the function returns true, and the person is included in the filtered array. If not, the function returns false, and the person is excluded.

This is just one example of how you can use Array.filter() to filter an array of objects by value. Depending on your specific use case, you may need to use more complex comparison logic or filter on different properties of the objects in the array. But with Array.filter( as your tool, you'll be able to filter your arrays with ease.

🌐
Technical Feeder
technicalfeeder.com › 2023 › 05 › typescript-javascript-filter-array-of-objects-by-property-value
TypeScript/JavaScript Filter array of objects by property value | Technical Feeder
May 22, 2023 - Let’s extract alcohol products from the array. We can simply filter them by comparing id > 300 but we will implement it in a different way. We can simply compare the data type by using instanceof. Another way is to check whether the object has the property name that is used in one of the classes.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-filter-object-array-based-on-attributes
How to Filter Object Array based on Attributes? - GeeksforGeeks
July 23, 2025 - One can use the filter() and reduce() functions in JavaScript to filter the object array based on attributes.
🌐
TutorialsPoint
tutorialspoint.com › filter-array-of-objects-whose-properties-contains-a-value-in-javascript
Filter array of objects whose properties contains a value in JavaScript
When we type "italy", we want to go through all the objects and all their properties to return the objects that contain italy. ... const arr = [{ name: 'Paul', country: 'Canada', }, { name: 'Lea', country: 'Italy', }, { name: 'John', country: 'Italy', }, ]; const filterByValue = (arr = [], query = '') => { const reg = new RegExp(query,'i'); return arr.filter((item)=>{ let flag = false; for(prop in item){ if(reg.test(item[prop])){ flag = true; } }; return flag; }); }; console.log(filterByValue(arr, 'ita'));
🌐
Zipy
zipy.ai › blog › find-object-by-property-in-javascript-array
find object by property in javascript array
April 12, 2024 - The function uses the filter() method to create a new array containing all objects whose specified property matches the given value. We then call this function with the books array, passing 'genre' as the property and 'Fiction' as the value, ...
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › object › filter object keys or values
Filter a JavaScript object's properties by keys or values - 30 seconds of code
January 14, 2024 - To accomplish this, we will leverage Object.entries() to get an array of the object's key-value pairs, then use Array.prototype.filter() to filter the key-value pairs based on the provided array.
🌐
Koenwoortman
koenwoortman.com › javascript-filter-array-by-object-property
Filter JavaScript array by object property
In JavaScript we can filter arrays by object value using the .filter() method, which is available on array objects. Lets for example assume that we have an array with the following options, and wish to filter based on the value of the required property.
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › typescript filter() example: filter array of objects by property
TypeScript filter() Example: Filter Array of Objects by Property
August 29, 2023 - // 1. Filter Array of Values const numArray: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; const evenNumArray = numArray.filter(n => n % 2 === 0); // [2, 4, 6, 8, 10] // 2. Filter Array of Objects const people: Person[] = [{ name: "Alice", age: ...
🌐
Codinhood
codinhood.com › nano › js › unique-items-in-object-by-property
How to Filter Unique Objects by a Property Value in JavaScript | Codinhood
The Set and Map methods are generally the most efficient for filtering unique objects by property value. The reduce() and find() methods can be less efficient due to their O(n^2) time complexity. Remove Duplicate Items In Arrays with the Javascript Set Object
🌐
freeCodeCamp
freecodecamp.org › news › filter-arrays-in-javascript
How to Filter an Array in JavaScript – JS Filtering for Arrays and Objects
November 7, 2024 - Then how do you filter an object in JavaScript? You can do this by converting the object to an array using any of the object static methods such as Object.keys(), Object.values() or Object.entries().
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › filter-object
How to Filter an Object with JavaScript - Mastering JS
function filterObject(obj, callback) { return Object.fromEntries(Object.entries(obj). filter(([key, val]) => callback(val, key))); } You can implement this more elegantly using Lodash's flow() function, which behaves like a pipe() function that ...