JS: Null-Safe Array Concat
You could make use of the ||
operator.
var a = [1, 2, 3]
var b = null
var c = [...a||[], ...b||[]]
console.log(c)
var c = [...(a || []), ...(b || [])]
This way if any array is null or undefined it will be replaced by an empty array