// filter using `thisArg`
const arr = [1,0,2,0,3,0,4,5,6,7,8,9,10,11,12,13,14];
// โญ๏ธ requires a normal function, doesn't work with arrow functions.
// โญโโโ โญ๏ธ โโโโฎ
const filtered = arr.filter(function(item) {
if (this.count < 10 && item > 0) { // โญ๏ธ this == thisArg
this.count++;
return true;
}
return false;
}, {count: 0});
// โฐโโ โญ๏ธ โโโฏ <--- `thisArg`