---
title: "Discussion on \"When to use logical OR vs. nullish coalescing in JavaScript\" | Hashnode"
description: "Discussion on \"When to use logical OR vs. nullish coalescing in JavaScript\". Introduction\nIt’s common to use the logical OR operator (||) to specify a default value:\nfunction createSong(title, artist) {\n    return {\n        title: title || '(Untitled)',\n        artist: artist || '(Unknown)',\n    }\n}\n\nES2020 adds the nullish c..."
url: "https://hashnode.com/posts/when-to-use-logical-or-vs-nullish-coalescing-in-javascript/6251f2b675dccb6f3431e938"
---

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

Discussion

# [When to use logical OR vs. nullish coalescing in JavaScript](https://zachsnoek.hashnode.dev/when-to-use-logical-or-vs-nullish-coalescing-in-javascript?utm_source=hashnode&utm_medium=feed)

Introduction It’s common to use the logical OR operator (||) to specify a default value: function createSong(title, artist) { return { title: title || '(Untitled)', artist: artist || '(Unknown)', } } ES2020 adds the nullish c...

Apr 9, 2022 · 3 min read · zachsnoek.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Zach Snoek](https://hashnode.com/@zachsnoek)

@zachsnoek · Washington, USA

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

Software Engineer

## Responses 1

Markdown supported · ⌘↵ to post

No responses yet.
