Dart has a similar idea to @claudiameadows proposal, called "collection if" and "collection for", but it only works on array.
Example from Dart's website:
var nav = [
'Home',
'Furniture',
'Plants',
if (promoActive) 'Outlet'
];
Such syntax would be nice in javascript too.