我刚刚开始使用dateJS,它似乎是一个很好的lib,但我显然错过了一些东西(可能是一个愚蠢的错误),但在我的函数中,我需要3个日期:clickedDate,weekStart & weekEnd。但使用dateJS我似乎覆盖每个变量。有人能指出我的错误吗?dateJS覆盖变量
var clickDate = myDate;
console.log(clickDate);
var weekStart = Date.parse(clickDate).last().monday();
console.log(clickDate);
var weekEnd = Date.parse(clickDate).next().sunday();
console.log(weekEnd);
console.log('break');
console.log(clickDate);
console.log(weekStart);
console.log(weekEnd);
控制台显示以下
Date {Wed Nov 30 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
Date {Mon Nov 28 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
Date {Sun Dec 04 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
break
Date {Sun Dec 04 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
Date {Sun Dec 04 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
Date {Sun Dec 04 2011 00:00:00 GMT-0700 (US Mountain Standard Time)}
[SSCCE](http://sscce.org)。一个很棒的JavaScript SSCCE工具:http://jsfiddle.net。什么是'myDate',一个字符串?顺便说一句,你是否想'console.log(clickDate)'连续两次? –
[It works for me](http://jsfiddle.net/LJJKn/)。 –
使用更多全局变量 –