TypeError: base.contacts is undefined - how can i define it?
<p>Receiving the above error in reference to the line <code>for ( var i = 0; i &lt; base.contacts.length; i++) {</code> and can't figure out how to resolve. Below is the relevant code section</p>

<pre><code> synckolab.addressbookTools.createTBirdObject = function (base, cards) {
    var card = null;
    if (base.type === "contact") {
        card = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance(Components.interfaces.nsIAbCard);
    } else if (base.type === "maillist") {
    card = Components.classes["@mozilla.org/addressbook/directoryproperty;1"].createInstance(Components.interfaces.nsIAbDirectory);
    card.isMailList = true;
    } else {
        return null;
    }

// for a mailing list add the entries
    if (base.type === "maillist") {
    card.dirName = this.getCardProperty(base, "DisplayName");
    if (this.haveCardProperty(base, "NickName")) {
        card.listNickName = this.getCardProperty(base, "NickName");
    }
    if (this.haveCardProperty(base, "Notes")) {
        card.description = this.getCardProperty(base, "Notes");
    }
    // fill the list
    for ( var i = 0; i &lt; base.contacts.length; i++) {
        var listCard = cards.get(this.getUID(base.contacts[i]));
        card.addressLists.appendElement(listCard, false);
    }
} else {
    // go through all elements of base
    for ( var field in base) {
        // skip our own stuff TODO: handle mailing lists!
        if (field !== "type" &amp;&amp; field !== "synckolab" &amp;&amp; field !== "ts" &amp;&amp; field !== "contacts" &amp;&amp; field !== "isMailList") {
            // copy the property from base to card
            this.setCardProperty(card, field, this.getCardProperty(base, field));
        }
    }
}

return card;
</code></pre>

<p>};</p>
