JS добавить в массив условно
const cond = false;
const arr = [
...(cond ? ['a'] : []),
'b',
];
// result:
//if cond true: ['a','b']
//if cond false: ['b']
// from https://2ality.com/2017/04/conditional-literal-entries.html
cemysf