Currently I check if sed object already exists as to not wipe it if it does, then create the object.
if (typeof result === 'undefined') {
results = {};
}
It’s just that I come from using PHP where you don’t really have to declare things as much as you do in JS.
Though I tend to use JS objects as I use arrays in PHP, as a way to temporarily store information which I need to access further down in a script.
This wouldn’t work if certain values (e.g.,
0,null, orfalse) should not be overwritten, but:This works because
||returns the first value if it is truthy or the second otherwise.undefined, along with some other values partially listed above, are falsy, but objects are truthy.