标签:巴西 console ima highlight time .com date i++ sch
var arr = [
{
id: "1",
date: "2018-07-27",
time: "10:00-12:00",
schedule: "开幕式"
},
{
id: "2",
date: "2018-07-27",
time: "12:00-14:00",
schedule: "世界杯||今日看点||法国队"
},
{
id: "3",
date: "2018-07-28",
time: "10:00-12:00",
schedule: "奥尼尔"
}, {
id: "4",
date: "2018-07-28",
time: "15:00-17:00",
schedule: "阿拉巴||巴西||俄罗斯"
}
]
var obj = {};//重新封装对象
for (var i = 0; i < arr.length; i++) {
var item = arr[i];//item
if (!obj[item[‘date‘]]) {
var _arr = [];
_arr.push(item);
obj[item["date"]] = _arr;
} else {
obj[item["date"]].push(item);
}
}
console.log(obj)
//对象的遍历
for (var key in obj) {
console.log(obj[key]);
}
var tab = {aa: 11111};
//console.log(tab.aa);
//console.log(tab[‘aa‘]);


标签:巴西 console ima highlight time .com date i++ sch
原文地址:https://www.cnblogs.com/songjn/p/9383825.html