1605 const i = this
1606 if (typeof e !== 'string') {
1607 return this.pushStack(
1608 k(e).filter(function () { 1609 for (t = 0; t < r; t++) if (k.contains(i[t], this)) return !0
1610 })
1611 )
1678 has: function (e) {
1679 const t = k(e, this)
1680 const n = t.length
1681 return this.filter(function () { 1682 for (let e = 0; e < n; e++) if (k.contains(this, t[e])) return !0
1683 })
1684 },
Array
has several methods for filtering, mapping, and folding.
If we forget to write return statement in a callback of those, it's probably a mistake.
If you don't want to use a return
or don't need the returned results, consider using .forEach
instead.
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
});
const bar = foo.filter(function(x) {
if (x) {
return true;
} else {
return;
}
});
const indexMap = myArray.reduce(function(memo, item, index) {
memo[item] = index;
return memo;
}, {});
const foo = Array.from(nodes, function(node) {
if (node.tagName === "DIV") {
return true;
}
return false;
});
const bar = foo.map(node => node.getAttribute("id"));