'how do I get some objects from an array of object [closed]

For Example: I have an array of object which consists 100 object in the array. and I want to show first 6 object in my react component. how do I loop that so it shows only those?



Solution 1:[1]

You can use slice to grab a range of elements and then map over it for your react component.

eg.

return 
<div>
  {elements.slice(0, 6).map((value) => <div>{value}</div>)}
</div>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Azarro