Better Programming

Advice for programmers.

Follow publication

Member-only story

5 Must-Know JavaScript Features That You Might Not Know

Gourav Kajal
Better Programming
Published in
8 min readMar 16, 2021
Man coding at desk
Photo by Nubelson Fernandes on Unsplash.

Have you ever been amazed by a developer using some cool JavaScript feature you had never seen before? Well, this happens to me all the time. And since programming is all about constant learning, I’m sure you’ve felt the same way at some point in time.

In this article, I’m going to share five JavaScript features that I always use that help my code look cleaner. Let’s get started.

1. Nullish Coalescing Operator (??)

Here’s the official definition from MDN Web Docs:

“The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.”

To understand this operator, let’s take an example.

Let’s say we have a simple JavaScript function that accepts three parameters (price, taxes, and description) and simply prints the total price of an item with taxes in the console. Something like this:

function calculatePrice(price, taxes, description) {    const total = price * (1 +…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Gourav Kajal
Gourav Kajal

Written by Gourav Kajal

Front End Developer by the day, and the Front End Developer by the night as well 😜 | Writer on Medium

Responses (1)

Write a response