是否可以将以下for循环转换为forEach?我在SO中检查了解决方案,但找不到与我相关的任何东西。
private wasFormChanged(currentValue) {
const fields = ['givenName', 'familyName', 'email', 'username'];
for (let i = 0; i < fields.length; i++) {
const fieldName = fields[i];
if (this.user[fieldName] !== currentValue[fieldName]) {
this.disableButton = false;
return;
}
}
this.disableButton = true;
}