jquery contains two each one is $ (). Each another is $.each the difference lies in the previous one is the built-in function of the jquery object and this is the traversal function of the object generally used in Ajax to get different object data to traverse to JSON for example jquery The Getjson shortcut method can conveniently obtain the JSON file in the specified URL jquery will be built into the call JS native eval function to parse JSON text into a JS object and then traverse through each global function to get the value syntax each (data, [Params],function (current item index, current item)) This is also a great difference from each of the built-in functions, and the index in the built-in function is an identifier used to indicate where to begin the traversal, followed by the element element that specifies how many elements to traverse and the global The index of each weight in the function refers to the key in each key value pair in JSON, which is key! In the jquery Basics tutorial, the author writes the appropriate code but fails to take the parameter to the correct sample code as follows
$.each (Data,function (entryindex,entry) {var html = entry[' term '}); The friend who has read this book must be very puzzled about entryindex in the end is what? In fact, Entryindex is the ' term ' but the author did not use the index to enter the key value directly from the JSON, through debugging to find the following problems generally translated into the index, personal opinion or should be the key to address the entry is a key value pairs of the property value is a field when this A property can be returned by using a key as an index to read the corresponding value through a similar get accessor, hoping to answer a friend who has doubts.