Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript和倾斜数组_Javascript_Jquery_Html - Fatal编程技术网

Javascript和倾斜数组

Javascript和倾斜数组,javascript,jquery,html,Javascript,Jquery,Html,我正在用JavaScript和HTML开发一个网页。我正在使用jQuery,必须突出显示选定的日期。我有一个数组: var events = [ { Title: "Five K for charity", Date: new Date("02/13/2013"), dir: "http://www.google.es" }, { Title: "Dinner", Date: new Date("02/25/2013") }, { Title: "Meeting with manager"

我正在用JavaScript和HTML开发一个网页。我正在使用jQuery,必须突出显示选定的日期。我有一个数组:

var events = [ 
{ Title: "Five K for charity", Date: new Date("02/13/2013"), dir: "http://www.google.es" }, 
{ Title: "Dinner", Date: new Date("02/25/2013") }, 
{ Title: "Meeting with manager", Date: new Date("03/01/2013") }
];
我的问题是,如何在该数组中添加元素?我尝试了很多东西,但我不知道怎么做。还有一个问题,这种数组的名称是什么

编辑:

我看到一件事。如果添加日期如“01/05/2013”,则数组如下所示:

Wed Feb 13 2013 00:00:00 GMT+0100 (Hora de verano romance)
Mon Feb 25 2013 00:00:00 GMT+0100 (Hora de verano romance)    
Fri Mar 01 2013 00:00:00 GMT+0100 (Hora de verano romance)
Sat Jan 05 2013 00:00:00 GMT+0100 (Hora de verano romance) 
并在日期选择器中打印日期。但如果我添加一个日期,如“2013年5月5日”,则:


你会看到吗?新的日期与其他日期不同。在这种情况下,日期选择器中的日期不是高位的。有人知道为什么吗?

该数组没有真正的名称,它只是一个s的名称。 要附加新的
对象
,必须执行以下操作:

events.push({Title: '...', ...}); //define the object to be appended
要定义新的日期对象,应使用此构造函数:

var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
//in this case it will be(month goes from 0 to 11)
new Date(2013, 4, 5); //this will be the 5th of May(which is 4)
日期对象有很多方法,您只需选择最适合您的方法即可


参考

这是一个完全正常的数组。什么是倾斜数组?它是一个对象文字数组。@Elseine,你在问为什么是1<代码>“05/05/2013”为
GMT+0200
,其他为
GMT+0100
,以及2。为什么
“01/05/2013”
一月
而你预期
五月
?我把它放在:事件推送({Title:“Metting”,Date:new Date(“05/2013”)});现在展示出来,你说的“展示”是什么意思?在HTML页面中显示?然后,我有一个函数,可以打印日期选择器。最初在数组中的3个日期是有优先级的,但是我添加的4个日期没有。我用所有新信息编辑了它们。
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
//in this case it will be(month goes from 0 to 11)
new Date(2013, 4, 5); //this will be the 5th of May(which is 4)