[英]Javascript - Array.prototype.slice.call causing performance issues
[英]the meaning of jQuery javascript: Array.prototype.slice.call
我想問一下以下代碼的含義:
$.fn.datepick = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
這些是來自jQuery插件文件'jquery.datepick.js'的2036 - 2037行
完整代碼如下所示:
/* 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 || {});
}
});
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.