Quantcast
Viewing latest article 1
Browse Latest Browse All 56

Comment by Ben Aston on In JavaScript, how can I conditionally assign value to object with destructuring and short circuit evaluation?

const { lastName } = objA || objB;: objA is truthy, and so it is the result of the OR operator. And it doesn't have a lastName property, hence the destructured variable lastName remains undefined.

Viewing latest article 1
Browse Latest Browse All 56

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>