In JavaScript, you can conditionally include an element in a literal array, but the syntax is a bit wonky using the spread operator:
const menu = [
{ type: 'item', title: 'Dashboard' },
...(config.url !== null ? [{
type: 'item', title: 'Applications'
}] : []),
]
You basically spread (...) the expression of an array with the element, or an empty array. It feels similar to mapping over Option, maybe?
What better syntax could there be?