我收到以下函數的意外標識符錯誤。javascript中的意外標識符錯誤
function merge (one, two) {
one.forEach(function(assign){
//////////this next line is throwing the error////////////
if (two.some(function(req) req.related == assign.rid)) {
if (one.some(function(iter) iter.rid == req.rid)) {
iter.quantity++;
} else {
one.push(req);
}
}
});
return one;
}
該函數旨在對一組對象進行操作。
我2/3DS確保您有使用匿名函數體周圍的括號,而且,混淆解析器爲試圖評估'req':'function(req){req.related == assign.rid}' – millimoose
爲了讓你的問題更容易回答,你應該考慮[做一個最小化,完整,可驗證的例子](https:// stackoverflow。 com/help/mcve) – millimoose
@millimoose你是對的,我害怕如果我省略了任何代碼,它會刪除必要的信息。我已經足夠新到JavaScript來犯這個錯誤。 – Suavocado