Created
January 4, 2021 22:03
-
-
Save codingedgar/8803cf55a93b52ac0d46aeb0181556a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.group('Logical OR assignment (||=)'); | |
const a = { duration: 50, title: '' }; | |
a.duration ||= 10; | |
console.log(a.duration); | |
a.title ||= 'title is empty.'; | |
console.log(a.title); | |
console.groupEnd(); | |
/* | |
Console: | |
Logical OR assignment (||=) | |
50 | |
title is empty. | |
*/ | |
// Other usefull example can be: | |
document.getElementById('lyrics').textContent ||= 'No lyrics.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment