1. jQuery's $. map Method:
$. Map (json, function (n) {return n ;});
This method was used to copy an array. Today, we use it to copy a record in the array. We found that the field name is lost, and then we found the second method.
2. Deep replication and light Replication
// Perform shallow copy (only copy the top-level non-object elements)
Var newObject = jQuery. extend ({}, oldObject );
// Deep replication (one layer to the bottom)
Var newObject = jQuery. extend (true, {}, oldObject );
The deep replication method is used. When copying an object, it is found that the field is lost.
3. Filter Arrays
I found the method of javascript array, but there was no filtering method. Later I found jQuery provided. I tried it and it was very useful.
$. Grep (jsonTmp, function (item)
{
Return item. LegendTitle = field;
}, False );
The function content can be written based on actual needs. If not, refer to jQuery's help, which is very detailed.
4. Sort arrays by the way
Json2.sort (function (a, B) {return a ["requiredColumn"] ["crimeTime"]> B ["requiredColumn"] ["crimeTime"]? 1:-1 });
This is easy to use.