Object Literal Conditional Properties
I’m constantly coming up against adding conditional properties to an Object, in an elegant fashion, but always have to end up doing:
var a = {};
if (someCondition) {
a.b = 5;
}
These were the top 10 stories published by James Hill in 2016. You can also dive into monthly archives for 2016 by using the calendar at the top of this page.