let variable2 = variable1 || '';
12 Good JavaScript Shorthand Techniques
Yuri Ramos
87057

I am sure this doesn’t work if variable1 is 0 or another falsey value.

Show your support

Clapping shows how much you appreciated Nigel Wade’s story.