P
P
pokhurev2020-06-12 20:38:04
JavaScript
pokhurev, 2020-06-12 20:38:04

How to limit the output of data from an array in JavaScript?

How to limit the output of data from an array in JavaScript?

There is an array: [{},{},{},{},{},{}, .... more than 500 indices];
I want to make sure that initially I get them 50 pieces, the rest only if necessary, again 50 each and not all at once.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-06-12
@dimoff66

const arr = [...]
let part = 1; // или в стейте

const getAnother50 = () => {
  return arr.slice((part - 1) * 50, part * 50)
}

Increase part if necessary.

D
Dima Polos, 2020-06-12
@dimovich85

You can make YOUR iterator, which will produce 50 elements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question