How can I filtering array of objects against varaible parameters in javascript

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How can I filtering array of objects against varaible parameters in javascript

I have an array like the following and I want to search only those values against gAssessorsCompanyAssociationsArray array where a user has entered something in any textbox and where any dropdown value is not "- Select One -". For example if a user has selected something in "Doctor Name" other than "- Select One -" then it should be part of my search against gAssessorsCompanyAssociationsArray array. If a user has entered something in "City" then it should be part of my search against gAssessorsCompanyAssociationsArray array.

I am storing if statement's expression is Profile_Filter variable and executing it using eval(which is not recommended).

Use the map method (see for exemple this MDN page), with somethig like this :

Code:

var nmb=[{fr:'zero',en:'zero'},{fr:'un',en:'one'},{fr:'deux',en:'two'},{fr:'trois',en:'three'},{fr:'quatre',en:'for'}];
// Define a new array
var evenNmb=[];
// Use of the map function to select the elements satisfying the condition
nmb.map(function(v,i){if (!(i%2)) evenNmb.push(v)});
// The result
alert(JSON.stringify(evenNmb))
// To filter elements which have a t letter in english
var tEnNmb=[];
nmb.map(function(v,i){if (-1<v.en.indexOf('t')) tEnNmb.push(v)});
alert(JSON.stringify(tEnNmb))

The map method calls a provided callback function (here an anonymous function) once for each element in an array, in order, and constructs a new array from the results (this new array has the same length as the original). But we use It only to build the new array with elements satisfying the condition...
The function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed. We use only the two first arguments .

Use the map method (see for exemple this MDN page), with somethig like this :

Code:

var nmb=[{fr:'zero',en:'zero'},{fr:'un',en:'one'},{fr:'deux',en:'two'},{fr:'trois',en:'three'},{fr:'quatre',en:'for'}];
// Define a new array
var evenNmb=[];
// Use of the map function to select the elements satisfying the condition
nmb.map(function(v,i){if (!(i%2)) evenNmb.push(v)});
// The result
alert(JSON.stringify(evenNmb))
// To filter elements which have a t letter in english
var tEnNmb=[];
nmb.map(function(v,i){if (-1<v.en.indexOf('t')) tEnNmb.push(v)});
alert(JSON.stringify(tEnNmb))

The map method calls a provided callback function (here an anonymous function) once for each element in an array, in order, and constructs a new array from the results (this new array has the same length as the original). But we use It only to build the new array with elements satisfying the condition...
The function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed. We use only the two first arguments .