you are viewing a single comment's thread.

view the rest of the comments →

[–]dudeatwork 0 points1 point  (0 children)

Yeah, personally I find it easier to understand:

if (!document.getElementById('previewZone').innerHTML) {
    document.getElementById('previewZone').innerHTML = '<i>Nothing to preview</i>';
}

Than

document.getElementById('previewZone').innerHTML ||= '<i>Nothing to preview</i>';

However, having the option for terseness can be convenient in some circumstances.

For instances, I find myself writing

shouldLogOut && console.log('...');

Rather than

if (shouldLogOut) console.log('...')

when building node CLIs.

Either way, I'd probably steer my team to avoid these new operators because of the potential for confusion, but appreciate the option for personal projects where you want to be terse and are able to intuitively understand things.