問題がreturn
はのは、試してみましょう必要があります{}
内の矢印機能するためのブラケット{}
ある
_.remove(previousNumberArray, (a) => _.some(this.removedQuestionCodes, (val, k) => {
return a.questionCode == val;
}));
それとも
_.remove(previousNumberArray, (a) => {
return _.some(this.removedQuestionCodes, (val, k) => {
return a.questionCode == val;
});
});
はのは、私の例を見てみましょう:2上記の解決策の
var fruits1 = ['Apple', 'Banana', 'Orange', 'Celery'];
_.remove(fruits1, fruit => {//BRACKET
//MUST HAVE RETURN KEYWORD
return _.indexOf(['Apple', 'Banana', 'Orange'], fruit) !== -1
});
var fruits2 = ['Apple', 'Banana', 'Orange', 'Celery'];
_.remove(fruits2, fruit => {//BRACKET
//DONT HAVE RETURN KEYWORD
_.indexOf(['Apple', 'Banana', 'Orange'], fruit) !== -1
});
console.log('fruits1',fruits1)
console.log('fruits2', fruits2)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.1/lodash.js"></script>
Nope.Noneあなたはなぜ知っているworking.Doですか?元の配列 'previousNumberArray'から項目を削除しません。 – Sampath
2つの配列の例を挙げることができますか?私はあなたの_ _omeにいくつかの問題があると思います –
このビデオをご覧ください:https://youtu.be/890YXOt6uwA – Sampath