Image for post
Image for post
Photo by Gabriel Santiago on Unsplash

Recently in one of my projects I had to remove duplicates from an array. Instead of looking up a npm package that could do it for me I chose to implement it myself. Here’s what I learned about this seemingly straightforward task.

The easiest way

The Set structure introduced in ES6 has made it unbelievably easy to remove duplicates from an array. It can be done with this one-liner:

function removeDuplicates<T>(collection: T[]) {
return [ Set(collection)];

The Set data structure takes an array of elements and removes all the duplicates from it. Set can handle both primitives and references, however it removes duplicates based on the === comparison so objects are only considered a duplicate if they reference the same place in memory. …

Image for post
Image for post
Photo by Annie Spratt on Unsplash

When dealing with a lot of records it is essential to create a way in which clients can specify how many they wish to obtain exactly. Returning records in chunks as opposed to dumping it all at once saves a lot of bandwidth and processing power.

A technique that splits the records into chunks is called pagination. A client sends two parameters: page and pageSize. Records are split into page number of pages - each page containing pageSize number of records.

Note that I am going to be explaining how to implement this using the Sequelize library specifically.

Paginating records with Sequelize comes down to including specific properties in a query object that we then pass to the model’s .findAll() method. The object has two properties - offset and limit - which indicate respectively how many records to skip and how many to take. …

Image for post
Image for post
Photo by Kevin Ku on Unsplash

Recently on Facebook David Smooke (the CEO of Hackernoon) posted an article in which he listed 2018’s Top Tech Stories. He also mentioned that if someone wished to make a similar list about say JavaScript he would be happy to feature it on the frontpage of Hackernoon.

In a constant struggle to get more people to read my work I could not miss this opportunity, so I immediately started to plan how to approach making such a list.

Since the year was coming to an end and I had limited time I decided not to search for the posts by hand but use my web-scraping skills instead. …


Maciej Cieślar

A JavaScript developer and a blogger @

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store