javascript conditional inside array code example
Example 1: conditional array element js
const cond = false;
const arr = [
...(cond ? ['a'] : []),
'b',
];
Example 2: js conditional array element
const cond = false;
const arr = [
...(cond ? ['a'] : []),
'b',
];
// ['b']