jQuery.get method : trying to understand source code
- get: function( url, data, callback, type ) {
- // shift arguments if data argument was omited
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = null;
- }
- return jQuery.ajax({
- type: "GET",
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- },
Above is the jQuery.get method from ajax.js . I was wondering why the 4th line is
is
- type = type || callback;
I think that line should be
- type = callback;
The way I see it, if data is function then type *must* be nil . If type has a value
then one parameter before type must have been dropped.
Am I missing something here?