фильтрация массива
function blender(arr, filters) {
return arr.filter(function(el) {
return filters.every(function(filter) {
return filter(el)
})
})
};
var projects = [
{
id: 'pb-15001',
name: 'ПБ-15.001',
area: 200,
thumbUrl: 'img/projects/p-15001/p15001-thumb.jpg',
floors: 400,
type: 'индивидуальный',
bedrooms: 4
},
{
id: 'pb-15001',
name: 'ПБ-15.001',
area: 300,
thumbUrl: 'img/projects/p-15001/p15001-thumb.jpg',
floors: 200,
type: 'индивидуальный',
bedrooms: 4
},
{
id: 'pb-15002',
name: 'ПБ-15.001',
area: 200,
thumbUrl: 'img/projects/p-15001/p15001-thumb.jpg',
floors: 100,
type: 'индивидуальный',
bedrooms: 4
}
]
fn = function(el) {
return el['floors'] == 100
}
fn2 = function(el) {
return el['area'] == 200
}
var test = blender(projects, [fn, fn2])
alert(JSON.stringify(test))