_(_.reverse(_newData)).map(_row => {
rowInTable = theTable.insertRow(1);
rowInTable.onclick = function(e){
$("tbody tr").removeClass("anti_bg_color");
$(this)[0].className += 'anti_bg_color';
}
}
-
reverse():用于颠倒数组中元素顺序。
(该表格为倒插顺序,[0] 是表头 [1]是新插入行) -
map():返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值。
按照原始数组元素顺序依次处理元素。
注意:map()不会对空数组进行检测;
注意:map()不会改变原始数组。 -
insertRow():在表格指定位置插入一个新行。