I would like to ask the meaning of the following code:
$.fn.datepick = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
These are lines 2036 - 2037 of jQuery plugin file 'jquery.datepick.js' from
I would like to ask the meaning of the following code:
$.fn.datepick = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
These are lines 2036 - 2037 of jQuery plugin file 'jquery.datepick.js' from
The full code look like this:
/* Attach the datepicker functionality to a jQuery selection.
@param options (object) the new settings to use for these instances (optional) or
(string) the command to run (optional)
@return (jQuery) for chaining further calls or
(any) getter value */
$.fn.datepick = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
if (isNotChained(options, otherArgs)) {
return plugin['_' + options + 'Plugin'].apply(plugin, [this[0]].concat(otherArgs));
}
return this.each(function() {
if (typeof options == 'string') {
if (!plugin['_' + options + 'Plugin']) {
throw 'Unknown command: ' + options;
}
plugin['_' + options + 'Plugin'].apply(plugin, [this].concat(otherArgs));
}
else {
plugin._attachPlugin(this, options || {});
}
});
};