September 2017
Intermediate to advanced
216 pages
6h 8m
English
If you want to implement pagination, you can use the slice() method. This method works just like take(), except that it accepts an offset to start slicing values from a collection:
const predicate = i => i % 2 === 0;const myRange = Range().filter(predicate);const page1 = myRange.slice(0, 5);const page2 = myRange.slice(5, 10);const page3 = myRange.slice(10, 15);page1.forEach(i => console.log('page1', i));// -> page1 0// -> page1 2// -> page1 4// -> page1 6// -> page1 8page2.forEach(i => console.log('page2', i));// -> page2 10// -> page2 12// -> page2 14// -> page2 16// -> page2 18page3.forEach(i => console.log('page3', i));// -> page3 20// -> page3 22// -> page3 24// -> page3 26// -> page3 28
We've created three pages ...
Read now
Unlock full access