0
我會盡量簡化我的情況:
offenses = {};
$(offenseTableID).find('tr').each(function (rowIndex, r) {
// building JSON object named "offense" with object with
// information from the table row.
// console.log shows It's correct. I typically have 3 rows
// showing different information.
// I am trying to extend offenses with what I constructed.
$.extend(offenses, offense);
});
// after I'm done I'm printing my "offenses" JSON object,
// expecting it to include everything that was added, but even if
// I $.extend multiple times - it only remembers the last JSON
// object that was $.extend'ed Why?
console.log(JSON.stringify(offenses));
$ .extend與其他PARAMS和覆蓋第一個參數最後的值贏得 – Saar
任何理由不在數組中存儲攻擊,只使用array.push? – Saar
所以沒有追加JSON對象? – JasonGenX