Making a minor change to a large "options" data structure
<p>I'm passing a large "options" object to another set of objects I'm instantiating in JavaScript.  The problem is, a very few of these "options" must change from object to object.  Making a completely separate options variable, with 1 of the many options changed, feels silly.  I also don't think I can just change the option on the same "options" object, as all of the objects will reference the same "options".</p>

<p>Below is the relevant code.</p>

<pre><code>    for (var i = 0; i &lt; invoices.length; i++) {

        var ura_original_column = { "column" : "ura_ppa_original",
                                    "on_update" : [format_ura],
                                    "display" : "URA" };

        if (invoices[i]["type"] == "P") {
            ura_original_column = { "column" : "ura_original",
                                    "on_update" : [format_ura],
                                    "display" : "URA" };
        }

        var options = { template_table  : "template_table",
                        template_total  : "template_total",
                        template_row    : "template_row",
                        template_text   : "template_text",
                        template_select : "template_select",
                        packet_id       : &lt;?val=packet["packet_id"]?&gt;,
                        products        : &lt;?val=json.dumps(products)?&gt;,
                        allow_new_rows  : &lt;?val=json.dumps(packet["status"] not in api.NON_MODIFIABLE_STATUS)?&gt;, 
                        on_table_focus  : on_table_focus,
                        on_row_update   : on_row_update,
                        on_new_row      : on_new_row,
                        columns : [{"column" : "product_code", 
                                    "display" : "Product"},
                                   {"column" : "transaction_type",
                                    "display" : "FFSU/MCOU",
                                    "editor" : "selectedit",
                                    "options" : ["FFSU", "MCOU"]},
                                    ura_original_column,
                                   {"column" : "ura_current",
                                    "display" : "Calculated URA"},
                                   {"column" : "units_current",
                                    "display" : "Current Units",
                                    "on_update" : [format_units],
                                    "show_total" : true},
                                   {"column" : "amount_claimed", 
                                    "display" : "Amt Claimed",
                                    "on_update" : [format_currency],
                                    "show_total" : true},
                                   {"column" : "scripts_current",
                                    "display" : "Scripts",
                                    "on_update" : [format_scripts],
                                    "show_total" : true},
                                   {"column" : "amount_medi_reimbursed", 
                                    "display" : "MEDI Amt", 
                                    "on_update" : [format_currency],
                                    "show_total" : true},
                                   {"column" : "amount_non_medi_reimbursed", 
                                    "display" : "Non-MEDI Amt", 
                                    "on_update" : [format_currency],
                                    "show_total" : true},
                                   {"column" : "amount_total_reimbursed", 
                                    "display" : "Total Amt", 
                                    "on_update" : [format_currency],
                                    "show_total" : true}]}

        var invoice_id = invoices[i]['invoice_id'];
        var transactions = transactions_by_invoice[invoice_id];
        var table = new Table.Table("invoice_" + invoice_id, options, transactions);

        tables.push(table);
    }
});
</code></pre>

<p>So, out of this gigantic options structure, only the "ura_original_column" changes.  This might be the best way to do it, but it feels like a bit of a hack.</p>

<p>Anyone have a more elegant suggestion?  </p>

<p>Thanks for taking the time to look.</p>
