首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Array.prototype.slice.call : jQuery javascript的含义

Array.prototype.slice.call : jQuery javascript的含义
EN

Stack Overflow用户
提问于 2013-11-14 21:25:35
回答 1查看 689关注 0票数 3

我想问一下以下代码的含义:

代码语言:javascript
复制
$.fn.datepick = function(options) {
    var otherArgs = Array.prototype.slice.call(arguments, 1);

这些是来自jQuery插件文件'jquery.datepick.js‘的2036 - 2037行

http://keith-wood.name/datepick.html

EN

回答 1

Stack Overflow用户

发布于 2013-11-14 21:51:54

完整的代码如下所示:

代码语言:javascript
复制
/* 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 || {});
        }
    });
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19978857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档