Javascript 生成";事件“;函数数组

Javascript 生成";事件“;函数数组,javascript,jquery,arrays,jquery-plugins,Javascript,Jquery,Arrays,Jquery Plugins,我编写了我的第一个jquery插件(日历)。现在一切正常,但我已将事件嵌入我的插件中,如: var days = [ new Event('9-5', 'test1', 1), new Event('9-7', 'test2', 8), new Event('9-8', 'test3', 2) ]; 现在,我从外部将事件“天”提交到我的插件,并使用: var days = [ ['9-5','test1', 1], ['9-7', 'tes

我编写了我的第一个jquery插件(日历)。现在一切正常,但我已将事件嵌入我的插件中,如:

var days = [
    new Event('9-5', 'test1', 1),
    new Event('9-7', 'test2', 8),
    new Event('9-8', 'test3', 2)       
];
现在,我从外部将事件“天”提交到我的插件,并使用:

var days = [
    ['9-5','test1', 1],
    ['9-7', 'test2', 8],
    ['9-8', 'test3', 2]      
];
$("#cal").calendar( { year: "2015", month: "9", events: days } ); 
在插件中,使用

var config = {
// default settings
    year: "2015",
    month: "9",
    events: ""
// ...
};
// change default settings
if (settings) { config = $.extend( {}, config, settings ); }
现在我的问题是,我尝试使用以下方法动态生成相同的事件数组:

var days = [];
config.events.each(function( index ) {
    days.push(new Event(config.events[index][0],config.events[index][1],config.events[index][2]));
});
但我得到了以下错误:

TypeError: config.events.each is not a function
以下是我的事件函数:

function Event(start,title, duration){ 

    if(start instanceof Date){
        this.start = start;   
    }
    this.title = title;
    this.dur = duration;
    this.end= new Date(this.start);
    ....
}
如何做到这一点? 非常感谢

编辑

我使用的每个函数都不正确:

 config.events.each(function( index ) {
必须是:

 $.each(config.events, function( index ) {

您没有正确使用。每个。$。每个()接受两个参数。第一个是数组/对象,第二个是回调函数

config.events.forEach(…)
错误消息
TypeError:config.events.each不是一个函数
非常明确