grep [passed parameter is a function that returns BOOL type]<script type= ' text/javascript ' src= "/jquery.js" ></script><script type= "Text/javascript" >$ (). Ready (function(){ varArray = [1,2,3,4,5,6,7,8,9]; varFilterarray = $.grep (Array,function(value) {returnValue > 5;//filter out more than 5 of }); for(vari=0;i<filterarray.length;i++) {alert (filterarray[i]); } for(Keyinchfilterarray) {alert (Filterarray[key]); } });</script>each[parameters passed in as process]<script type= ' text/javascript ' src= "/jquery.js" ></script><script type= "Text/javascript" >$ (). Ready (function(){ varAnObject = {One:1,two:2,three:3};//to the JSON array each$.each (AnObject,function(name,value) {alert (name); alert (value); }); varAnarray = [' One ', ' both ', ' three ']; $.each (Anarray,function(n,value) {alert (n); alert (value); } ); });</script>inarray[used to return the subscript of a value in an array]<script type= ' text/javascript ' src= "/jquery.js" ></script><script type= "Text/javascript" >$ (). Ready (function(){ varAnarray = [' One ', ' both ', ' three ']; varindex = $.inarray (' both '), Anarray); alert (index);//returns the value of the key in the array, returning 1Alert (Anarray[index]);//value is a });</script>map[function with return value type]<script type= ' text/javascript ' src= "/jquery.js" ></script><script type= "Text/javascript" >$ (). Ready (function(){ varstrings = [' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' S ', ' 6 ']; varValues = $.map (strings,function(value) {varresult =NewNumber (value); returnIsNaN (Result)?NULL: result;//isnan:is abbreviation for not a number } ); for(Keyinchvalues) {alert (Values[key]); } });</script>To traverse a JSON object:<script>varJSON = [{dd: ' SB ', AA: ' Dongdong ', RE1:123},{CCCC: ' DD ', LK: ' 1qw '}]; for(vari=0,l=json.length;i<l;i++){ for(varKeyinchJson[i]) {Alert (Key+ ': ' +Json[i][key]); }}</script>The traversal JSON object has the following JSON object:varobj ={"name": "Feng Juan", "Password": "123456″," department ":" Technical department "," Sex ":" female "," old ": 30}; Traversal method: for(varPinchobj) {STR= Str+obj[p]+ ', '; return str;}
jquery filter array grep, each, InArray, map usage and traverse son object (GO)