var Food={
fruits: [
{ name: "Banana", color: "Yellow" },
{ name: "Apple", color: "Red" },
{ name: "Grapefruit", color: "Orange" },
{ name: "Kiwi", color: "Green" }
],
vegetables: [
{ name: "Carrot", color: "Orange" },
{ name: "Turnip", color: "Purple" },
{ name: "Rutabaga", color: "Yellow" },
{ name: "Sweet Potato", color: "Orange" }
],
luger: [
{name:"luger",color:"red"},
{name:"lee",color:"pink"}
]
};///////////////////下面的代码是想设计成上面的样式,大家看看设计上有问题吗?///////////////////
var toDoList = []; // 加了这个定义,你忘了定义它
var Luger=(function(){ // 这里用了闭包
/**
* ToDo 对象
*/
function ToDo(day,title,content,time,rank,color) {
this.day = day;
this.title = title;
this.content = content;
this.time = time;
this.rank = rank;
this.color = color;
}
return { // API 函数定义返回给 Luger
newToDo:function(day,title,content,time,rank,color){
return new ToDo(day,title,content,time,rank,color);
},
addToDo:function(toDo){
if(typeof(toDoList[toDo.day])=="undefined"){
toDoList[toDo.day] = [toDo];
} else {
toDoList[toDo.day].push(toDo);
}
},
newAndAddToDo:function(day,title,content,time,rank,color){
var toDo = this.newToDo(day,title,content,time,rank,color);
this.addToDo(toDo);
}
}})();
$(document).ready(function(){
//测试代码示例:
var todo = Luger.newToDo("2013-04-02","title1","content1",new Date(),1,"red");
Luger.addToDo(todo);
var todo = Luger.newToDo("2013-04-02","title2","content2",new Date(),2,"blue");
Luger.addToDo(todo);
Luger.newAndAddToDo("2013-04-02","title3","content3",new Date(),3,"blue");
alert(toDoList["2013-04-02"].length);
});jsonjavascript
fruits: [
{ name: "Banana", color: "Yellow" },
{ name: "Apple", color: "Red" },
{ name: "Grapefruit", color: "Orange" },
{ name: "Kiwi", color: "Green" }
],
vegetables: [
{ name: "Carrot", color: "Orange" },
{ name: "Turnip", color: "Purple" },
{ name: "Rutabaga", color: "Yellow" },
{ name: "Sweet Potato", color: "Orange" }
],
luger: [
{name:"luger",color:"red"},
{name:"lee",color:"pink"}
]
};///////////////////下面的代码是想设计成上面的样式,大家看看设计上有问题吗?///////////////////
var toDoList = []; // 加了这个定义,你忘了定义它
var Luger=(function(){ // 这里用了闭包
/**
* ToDo 对象
*/
function ToDo(day,title,content,time,rank,color) {
this.day = day;
this.title = title;
this.content = content;
this.time = time;
this.rank = rank;
this.color = color;
}
return { // API 函数定义返回给 Luger
newToDo:function(day,title,content,time,rank,color){
return new ToDo(day,title,content,time,rank,color);
},
addToDo:function(toDo){
if(typeof(toDoList[toDo.day])=="undefined"){
toDoList[toDo.day] = [toDo];
} else {
toDoList[toDo.day].push(toDo);
}
},
newAndAddToDo:function(day,title,content,time,rank,color){
var toDo = this.newToDo(day,title,content,time,rank,color);
this.addToDo(toDo);
}
}})();
$(document).ready(function(){
//测试代码示例:
var todo = Luger.newToDo("2013-04-02","title1","content1",new Date(),1,"red");
Luger.addToDo(todo);
var todo = Luger.newToDo("2013-04-02","title2","content2",new Date(),2,"blue");
Luger.addToDo(todo);
Luger.newAndAddToDo("2013-04-02","title3","content3",new Date(),3,"blue");
alert(toDoList["2013-04-02"].length);
});jsonjavascript
解决方案 »
- jquery菜单选项
- 表单自动提交 超郁闷问题
- 关于onmouseover问题,关于图片处理,如何使用JS
- 除了 VML语言 能画图 还有其它什么吗
- 如何自动加载网页播放器的文件...急啊!!
- javascript 中子页面关闭时父页面重新生成 各位大哥大姐帮帮忙
- iframe 函数传递问题!
- 請問:我可以在提交頁面時得到所有被選中的CHECKBOX嗎?
- ★★★发布软件,能格式化/缩进/美化C/C++, Java, Pascal, C#, VB, VB.NET, VBScript和JavaScript源代码的工具!【前200名朋友狂送注册码
- 帧页面定时刷新,有办法不影响到整个页面吗?
- 动态获取Chart.series.type属性值(ExtJS)
- jquery选择器问题
fruits: [
{ name: "Banana", color: "Yellow" },
{ name: "Apple", color: "Red" },
{ name: "Grapefruit", color: "Orange" },
{ name: "Kiwi", color: "Green" }
],
vegetables: [
{ name: "Carrot", color: "Orange" },
{ name: "Turnip", color: "Purple" },
{ name: "Rutabaga", color: "Yellow" },
{ name: "Sweet Potato", color: "Orange" }
],
luger: [
{name:"luger",color:"red"},
{name:"lee",color:"pink"}
]
};
///////////////////下面的代码是想设计成上面的样式,大家看看设计上有问题吗?///////////////////
var toDoList = {}; // 加了这个定义,你忘了定义它。这里改成这个,不然是个空数组,又给这个空数组强加了2013-04-02的属性
var Luger=(function(){ // 这里用了闭包
/**
* ToDo 对象
*/
function ToDo(day,title,content,time,rank,color) {
this.day = day;
this.title = title;
this.content = content;
this.time = time;
this.rank = rank;
this.color = color;
}
return { // API 函数定义返回给 Luger
newToDo:function(day,title,content,time,rank,color){
return new ToDo(day,title,content,time,rank,color);
},
addToDo:function(toDo){
if(typeof(toDoList[toDo.day])=="undefined"){
toDoList[toDo.day] = [toDo];
} else {
toDoList[toDo.day].push(toDo);
}
},
newAndAddToDo:function(day,title,content,time,rank,color){
var toDo = this.newToDo(day,title,content,time,rank,color);
this.addToDo(toDo);
}
}
})();
$(document).ready(function(){
//测试代码示例:
var todo = Luger.newToDo("2013-04-02","title1","content1",new Date(),1,"red");
Luger.addToDo(todo);
var todo = Luger.newToDo("2013-04-02","title2","content2",new Date(),2,"blue");
Luger.addToDo(todo);
Luger.newAndAddToDo("2013-04-02","title3","content3",new Date(),3,"blue");
alert(toDoList["2013-04-02"].length);
});