JavaScript is fundamentally object oriented, everything is an object... and most objects can contain every other kind of object... do instead of a global called myDataUrl, you could append a .data_url property to the object you created with that data.