---
title: "Discussion on \"Why you should use ?? instead of ||\" | Hashnode"
description: "Discussion on \"Why you should use ?? instead of ||\". We often see and write things like this:\nfunction sayHey(name) {\n    name = name || \"Precious\";\n    console.log(`Hey ${name}`);\n}\n\nsayHey(\"Morty\"); //Hey Morty\nsayHey(); //Hey Precious\n\nBut did you know that the ?? operator, known as the nullish coal..."
url: "https://hashnode.com/posts/why-you-should-use-nullish-coalescing-instead-of-logical-or/65af88fbaedade3a929795e6"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why you should use ?? instead of ||](https://hardnold.hashnode.dev/why-you-should-use-nullish-coalescing-instead-of-logical-or?utm_source=hashnode&utm_medium=feed)

We often see and write things like this: function sayHey(name) { name = name || "Precious"; console.log(\`Hey ${name}\`); } sayHey("Morty"); //Hey Morty sayHey(); //Hey Precious But did you know that the ?? operator, known as the nullish coal...

Jan 23, 2024 · 3 min read · hardnold.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#operators](https://hashnode.com/tag/operators)
-   [#falsy](https://hashnode.com/tag/falsy)
-   [#javascript-truthy-and-falsy](https://hashnode.com/tag/javascript-truthy-and-falsy)

## Written by

[Daniel Engelhardt](https://hashnode.com/@hardnold)

@hardnold · Düsseldorf, Germany

  
[View profile](https://hashnode.com/@hardnold)

CTO / Team lead @ evolute.app, professional Mario Kart driver

I'm a passionate webdeveloper, introvert and nerd at heart. I build and lead the greatest team in the world at my startup "Evolute". Let's connect and talk about nerdy things or collaborations ✌️

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
