Hallo,
Das führt dazu, dass das halt so aussieht:
if (typeof config == 'undefined') {
var config = new Array();
}
config.id123 = 'foo';
<http://stackoverflow.com/questions/2703102/typeof-undefined-vs-null>
darin: "If the variable is declared (either with the var keyword, as a function argument, or as a global variable), I think the best way to do it is:
if (my\_variable === undefined)
jQuery does it, so it's good enough for me :-)"
Also die zwei Gleichheitszeichen bergen u.U. Überraschungen.
Ansonsten verstehe ich Dein Problem nicht. Du kannst doch Dein Objekt deklarieren. Oder Du übergibst Deine Werte einer Funktion, die am Ende ein gewünschtes Objekt erstellt.
sinngemäß:
ObjectCreator.collect();
irgendwo im Code.
myObj = ObjectCreator.create();
am Ende.
Gruß
jobo