我在比较两个数组的元素并过滤出匹配值时遇到了一些问题。我只想返回不包含在wordsToRemove
之内的数组元素。使用.filter比较两个数组并返回不匹配的值
var fullWordList = ['1','2','3','4','5'];
var wordsToRemove = ['1','2','3'];
var filteredKeywords = fullWordList.forEach(function(fullWordListValue) {
wordsToRemove.filter(function(wordsToRemoveValue) {
return fullWordListValue !== wordsToRemoveValue
})
});
console.log(filteredKeywords);