tslint错误使用箭头函数代替函数表达式

时间:2018-09-30 18:20:56

标签: ecmascript-6 tslint

我遇到了tslint警告,我对es6还是陌生的,但在语法上仍然有些困难。因此,我不确定如何在箭头函数中转换此代码。

enter image description here

这是我的代码:

 let deletedQuestions = origQuestions.filter(function(obj) {
            return !updatedQuestions.some(function(obj2) {
                return obj.value == obj2.value;
            });
          });
          console.log(deletedQuestions);

          let addedQuestions = updatedQuestions.filter(function(obj) {
            return !origQuestions.some(function(obj2) {
                return obj.value == obj2.value;
            });
          });

1 个答案:

答案 0 :(得分:0)

我相信会

let deletedQuestions = origQuestions.filter(obj =>
  !updatedQuestions.some(obj2 => obj.value == obj2.value)) console.log(deletedQuestions);
let addedQuestions = updatedQuestions.filter(obj =>
  !origQuestions.some(obj2 => obj.value == obj2.value))

对吗?