使用以下代码我想将filtered[i]
输出推送到单个数组而不是多个数组。
知道我该怎么做?
var checkObject;
var filtered = s.Data.results.filter(function(el) {
return el.result.indexOf(option) > -1
});
for (var i = 0; i < filtered.length; i++) {
checkObject = filtered[i].path === 3;
if (checkObject) {
var object = [],
hash = Object.create(null),
notIn = [];
object.push(filtered[i]);
console.log(object);
//
object.forEach(function(a) {
a.result.forEach(function(b) {
hash[b] = true;
});
});
notIn = s.Data.choices.filter(function(a) {
return !hash[a.choice];
});
console.log(notIn);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>