Member-only story

Hipsterify your JavaScript: unusual tricks to make your code simpler

Roman Sedov
2 min readAug 6, 2021

--

Modern JavaScript gives developers a lot of opportunities to write code faster and to make it simpler to read. All you need is to explore its new features and to adopt them as a rule in your team.

Here are some tricks that I use to simplify the code of mine and the people whom I review. Some of them can look a bit weird for the first time but they are seen well after you meet them in code a couple of times.

Spread it

The spread operator has already become a classic. I certainly don’t want to teach you how to copy an array or merge two objects. But let me show a couple of more unusual samples to show its power.

How to get unique values in an array

Spread allows us to get all the values of a set that are unique by its definition.

Add a property if condition

This is one of my favorite tricks with the spread operator because it simplifies a lot of code and has many…

--

--

Roman Sedov
Roman Sedov

Written by Roman Sedov

Angular Google Developer Expert

No responses yet