JavaScript Objects and public variables
<p>I've trying to create a javascript object with public methods and public variables:</p>

<pre><code>jeeni.DataGrid = (function(elementId){
    var divId = elementId;
    var div;
    var saveUrl;
    var columns;
    var dataUrl;

    var validate = function(){
        console.log("divId: " + (divId));
        console.log("div: " + div);
        console.log("saveUrl: " + saveUrl);
        console.log("columns: " + columns);
        console.log("dataUrl: " + dataUrl);
    };

    return {
        toString:validate,
        dateURL:dataUrl,
        saveURL:saveUrl,
        columnDefs:columns
    };

});
</code></pre>

<p>and I use it like this:</p>

<pre><code>&lt;script&gt;
    $(document).ready(function() {

        var grid = new jeeni.DataGrid("myDataGrid");

        grid.saveURL = "http://www.jeeni.co.uk/grid/save";
        grid.dataURL = "http://www.jeeni.co.uk/grid/data";
        grid.columnDefs = "[{text:'Column1',width:75}, {text:'Column2',width:150}]";
        grid.toString();
    });
&lt;/script&gt;
</code></pre>

<p>But at the console I get:</p>

<pre><code>divId: myDataGrid
div: undefined
saveUrl: undefined
columns: undefined
dataUrl: undefined
</code></pre>

<p>Can anyone explain why the undefined variables are undefined. Doesn't the return make them public? And how do I get them to be assignable without having to use getters and setters.</p>

<p>Thanks</p>
