<script type= "Text/javascript" >//according to Sys_time and Loc_time. varTMP = [ { "id": 1, "Sys_time": "2015-03-09 15:15:08",//repeat with ID 2"Loc_time": "2015-03-09 15:16:38" }, { "ID": 2, "Sys_time": "2015-03-09 15:15:08", "Loc_time": "2015-03-09 15:15:38",//Repeat with ID 3 (but since Sys_time has been duplicated with ID 1, it will not actually participate in Loc_time) }, { "ID": 3, "Sys_time": "2015-03-09 15:16:08", "Loc_time": "2015-03-09 15:15:38", }, { "ID": 4, "Sys_time": "2015-03-09 15:17:08", "Loc_time": "2015-03-09 15:17:38", } ] //For (n in tmp) { //tmp[n].sys_time = new Date (tmp[n].sys_time). GetTime (); // } varresult = [], hash = {}; Hash_ = {} for(vari = 0; i<tmp.length; i++) { varElem =Tmp[i].sys_time; varElem_ =Tmp[i].loc_time; if(!Hash[elem]) { if(!Hash_[elem_]) {Result.push (tmp[i]); HASH_[ELEM_]=true; }; Hash[elem]=true; }} console.log (Result)</script>
Results:
[ { "id": 1, "sys_time": "2015-03-09 15:15:08", "loc_time": "2015-03-09 15:16:38 " }, { " id ": 3, " sys_time ":" 2015-03-09 15:16:08 ", "Loc_time": "2015-03-09 15:15:38", }, { "id": 4, "sys_time": "2015-03-09 15:17:08 ", " loc_time ":" 2015-03-09 15:17:38 ", }]
The JS object array is weighed against the elements in the object.