我一直在使用这行代码来匹配这两个数组,以使它们具有相同的数据量。
var items = viewModel.Date1;
var items2 = viewModel.Date2;
items = items2.map( row =>
//is there a matching row in items?
items.filter( r => r.theString == row.theString).length == 0 ?
//if not, fill with zeros
{theString:0, theCount:0} :
//if there is, return the items' row
items.filter( r => r.theString == row.theString)[0] );
在IE中使用=>
会出现语法错误。
如何重写以使其在Firefox,Chrome和IE中都能正常工作?