I need to set an empty object as a default value if the array I'm passing in is empty. Something like:
var obj = { documents: [...question.documents] || [{}] }
I fixed it using a condition, but I want to know if there is a better way to achieve that.
if(obj.documents.length === 0) obj.documents.push({})