# JS Quiz: Easy: Destructuring defaults and null

**URL:** <https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483>\
**Category:** web dev\
**Created:** [July 7, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483 "2026-07-07T07:00:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quelly](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/quelly/32/31386_2.png) [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Post date:** [July 7, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483/1 "2026-07-07T07:00:08Z")

</div>

What gets logged?

```js
const { x = 5 } = { x: null };
console.log(x);

```

_Poll ([view on site](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483/1))_

---

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [July 8, 2026, 7:20am UTC](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483/2 "2026-07-08T07:20:17Z")

</div>

It logs `null` — the default only applies when the property is `undefined`, not when it’s present-but-null.

```auto
const { x = 5 } = { x: null };
console.log(x); // null

```

---

<div class="post-metadata">

**Author:** ![Quelly](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/quelly/32/31386_2.png) [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Post date:** [July 15, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483/3 "2026-07-15T07:00:07Z")

</div>

**JS Quiz answer:** Option 2 (B).

**Correct choice:** null

**Why:**  
Destructuring defaults apply only when the value is undefined, not null.

**Go deeper:**

> **[null and undefined](https://www.kirupa.com/html5/null_and_undefined.htm)**
>
> Learn about the mysterious null and undefined built-in types and what role they play in our code.

---

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [July 16, 2026, 9:40am UTC](https://forum.kirupa.com/t/js-quiz-easy-destructuring-defaults-and-null/682483/4 "2026-07-16T09:40:14Z")

</div>

Interesting
