I am doing a node app where I came across a scenario where If I have an array of 1000 elements and pass it from Node - Express (Backend) to ejs(Only HTMl and CSS Bootstrap) page which is a front end and loop through it , it takes lot of time to display the elements.Can you suggest a way to efficiently display the items from the array and display the items.
<% ordersArray.reverse().forEach(function(values){ %>
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><%= values.firstName %></h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<% }) %>
In the above example ordersArray contains 1000-2000 elements.
inside the user Schema I have a fields called as posts which is stores the post in an array of JSON for example.[{......},{.......},{........},{. .........}].Now how do I limit this and get only few records and keep a track of it.