DEV Community

frk-ozbk
frk-ozbk

Posted on • Edited on

7 2

What is Syntactic Sugar

Today I wanted to talk about syntactic sugar and how it improves you and your team coding life.

In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express.

Let's look at this example. I have an array of items. And I want to check every item is selected or not?

Classic Javascript Loop

example-1

Javascript array method - .every()

example-1

Which one do you prefer using? I think .every() is cleaner and it explains itself.

Let's look at example two. This time I want to select all items if all items are not selected. If all items are selected, I want to remove all items.

Classic Javascript Loop

example-2

Javascript array method - .forEach()

example-2

It is not shorter too much. But still, it is shorter and it is self-explanatory.

Conclusions

Syntactic sugar improves your coding life. Believe me every line matters.
If you are using React or Vue you will have many methods and JSX or Templates in a single component. That is for this post.

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

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

Okay