Skip to content

Instantly share code, notes, and snippets.

@rochapablo rochapablo/.js
Created Aug 8, 2018

Embed
What would you like to do?
Array of Object with Pagination
console.clear();
var data = [];
for (var i = 1; i <= 15; i++) {
var uuid = faker.random.uuid();
data.push({
id: i,
name: faker.name.findName(),
email: faker.internet.email(),
department: faker.commerce.department()
});
}
var total = data.length;
var page = 1;
var limit = 5;
var start = Math.max(page - 1, 0) * limit;
var end = start + limit;
data = data.slice(start, end);
console.log({ data: data, length: data.length, total: total });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.