fill 2D array
IIFE
arr.containsSubarray() - closure with internal parameter ⭐️
// 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`
JS - Get top 5 max elements from array
How to limit for 10 results the array.filter?
Last updated 2 years ago
Was this helpful?