DEV Community

Kyle Trahan
Kyle Trahan

Posted on

1

Ready Set() Go

During our recent mod2 project we ran into an issue of needing to return a unique list while using Javascript. After doing a little research we were able to discover the world of Set(). Set() was very useful in that it allows you to create a collection of items that are unique.

We were able to assign a variable to new Set(), which creates an empty set. Then using set().add(value) we were able to add a unique list of values to a collection. Conveniently Set() returns this new list as an object. Once you have this object you are able to use forEach in order to iterate through your object and apply specific functions.

Alt Text

Set() also has a few other uses. You are able to delete elements from the collection in one of two ways. You can either use set().delete(value) which will return a boolean response regarding whether or not the value was deleted. Alternatively you can use set().clear in order to clear the entire collection, which will return an undefined value.

This is merely brushing the surface of the functionality while using Set(). I highly recommend doing a little research if you find yourself in need of a unique list while using javascript!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay