javascript - Find index in array of objects -
I would like to search the index in the array conditions in the array are objects, and I want to filter them on properties. I know which keys I want to filter and their value
for now I have given the code to filter the data and returns the object data to me, but not an array of arrays. "Data": {"text": "one", "site-id": "1", "irritation": "default", "user id": "8", "time "", "User": "7", "time": 1374156747}, {"text": "two", "site-id": "1", "irritation": "default", "user-id": 1374156735}]; Var filter = {userid: '7', Chid: 'default'}; Function getIndexOfArray (list, support) {var pnames = _keys (props) back _.find (list, function (obj) {return_.all (pnames, function (pname) {return obj [pname] == PROP [Pname] })}}}} Check = getIndexOfArray (data, filterParam); // '2', no key = & gt;
(var intIndex = 0; intIndex & lt ; Data.length; intIndex ++) {everyobj = data [intIndex]; Var flag = true; (For filter in para a) {if (everyobj.hasOwnProperty (k)) {if (everyobj [k] .toString ()! = Filterparams [k] .toString ()) {flag = false; }}} If (flag) {alert (intIndex); }
}
Comments
Post a Comment