the meaning of jQuery javascript: Array.prototype.slice.call
the meaning of jQuery javascript: Array.prototype.slice.call
我想问一下以下代码的含义:
$.fn.datepick = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
这些是jQuery插件的第2036-2037行文件 'jquery.datepick.js' 来自
http://keith-wood.name/datepick.html
完整代码如下所示:
/* 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 || {});
}
});
};
相关文章:
- 如何迭代Array.prototype函数
- 为什么可以't我用Set对象调用Array.prototype.map
- 复选框:使用Array.prototype.forEach调用推送选中订单,
- 转换类似数组的对象Array.prototype.slice或Array.from
- 为什么要将Array.prototype.slice.call与参数一起使用
- 为什么 Array.prototype.reduce() 不接受 Map 对象作为初始值
- 如何在返回单个对象时递归使用 Array.prototype.find()
- 如果 Array.prototype.map() 没有返回,它是否被正确使用
- Array.prototype.fill() different from fill as I go
- moment:Array.prototype.some在null或未定义时被调用
- Array.prototype.stice.call()的内部工作
- Array.prototype.splice.call-不适用于querySelectorAll('.class
- Array.prototype.reduce的实际用途是什么
- "可变变量可从闭包“”访问;在传递给Array.prototype.every的函数中
- [].slice vs Array.prototype.slice
- 使用Javascript的高级Array.prototype.filter
- ES6 Array.prototype.values should'它现在还不存在
- 为什么Array.prototype不是Array的实例
- Array.prototype.slice.call如何在getElementsByClassName的重新创建中工作
- 为什么使用Array.prototype.map.call而不是Array.map.call