I am currently working through Learning jQuery 4th edition, where I am given an example of a form that takes a single text input. The form, when submitted, looks at jQuery documents for the entered string, extracts it as a JSONP object, and displays it.
In this example, I am provided with the following code snippet
//more code var buildItem = function(item) { var title = item.name, args = [], output = '<li>'; if (item.type == 'method' || !item.type) { if (item.signatures[0].params) { $.each(item.signatures[0].params, function(index, val) { args.push(val.name); }); } title = (/^jQuery|deferred/).test(title) ? title : '.' + title; title += '(' + args.join(', ') + ')'; } else if (item.type == 'selector') { title += ' selector'; } output += '<h3><a href="' + item.url + '">' + title + '</a></h3>'; output += '<div>' + item.desc + '</div>'; output += '</li>'; return output; }; //more code
I'm having trouble understanding the string
$.each(item.signatures[0].params, function(index, val) { args.push(val.name); });
in particular, what does .params actually do? I understand that it accesses files from within the signature in the returned object, but I do not see any .params in the returned object, and I cannot find any documentation for the .params ..
Any help would be appreciated.
jsFiddle can be found here: http://jsfiddle.net/QPR4Z/2/
javascript jquery
Kenneth .J
source share