Given:
var a = [1, 2, 3]
var b = null
I need to:
var c = [...a, ...b]
.. but that does not work when a
or b
is null of course. So in this example b
should just not be added, resulting in c = [1, 2, 3]
. If both a
and b
are null (or undefined), the result should be [].
Are there any shorthands to avoid having to write two if
-statements?