# Logical assignment for default assignments

**URL:** <https://es.discourse.group/t/logical-assignment-for-default-assignments/544>\
**Category:** 💡 Ideas\
**Created:** [November 13, 2020, 11:41pm UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544 "2020-11-13T23:41:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jun-sheaf](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jun-sheaf/32/505_2.png) [@jun-sheaf](https://es.discourse.group/u/jun-sheaf)\
**Post date:** [November 13, 2020, 11:41pm UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/1 "2020-11-13T23:41:13Z")

</div>

A proposal for using the logical assignments `||=` and `??=` in default assignment in function arguments and destructuring.

I've made a repo here: [https://github.com/jun-sheaf/proposal-logical-default-assignment](https://github.com/jun-sheaf/proposal-logical-default-assignment).

Looking for feedback (and a champion 🏆)

---

<div class="post-metadata">

**Author:** ![jun-sheaf](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jun-sheaf/32/505_2.png) [@jun-sheaf](https://es.discourse.group/u/jun-sheaf)\
**Post date:** [November 19, 2020, 11:27pm UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/2 "2020-11-19T23:27:38Z")

</div>

Bump (can we bump here 🤭)

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [December 15, 2020, 9:19am UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/3 "2020-12-15T09:19:11Z")

</div>

Have you considered including 'logical and' `&&=` for completeness?

---

<div class="post-metadata">

**Author:** ![jun-sheaf](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jun-sheaf/32/505_2.png) [@jun-sheaf](https://es.discourse.group/u/jun-sheaf)\
**Post date:** [December 15, 2020, 10:46am UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/4 "2020-12-15T10:46:35Z")

</div>

What would be the use case?

---

<div class="post-metadata">

**Author:** ![claudiameadows](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudiameadows/32/126_2.png) [@claudiameadows](https://es.discourse.group/u/claudiameadows)\
**Post date:** [January 3, 2021, 5:10pm UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/5 "2021-01-03T17:10:57Z")

</div>

I've far more often wanted `??` behavior than strictly "not `undefined`" on function arguments, and it's not possible to migrate to default parameters without causing breakage in many existing libraries.

---

<div class="post-metadata">

**Author:** ![uniqname](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/uniqname/32/2062_2.png) [@uniqname](https://es.discourse.group/u/uniqname)\
**Post date:** [April 9, 2024, 5:24pm UTC](https://es.discourse.group/t/logical-assignment-for-default-assignments/544/6 "2024-04-09T17:24:05Z")

</div>

I was just thinking about proposing this and found that it already had been proposed. I completely agree with [claudiameadows](https://es.discourse.group/u/claudiameadows). It is often the case that I want default parameters to replace both `undefined` and `null`. That is my primary use case. I can imagine scenarios where other logical assignments might be desired.

I was originally optimistic that extractors could be the answer, but logical assignment seems a very natural and low hanging opportunity.
