How can I create a JavaScript object constructor in a module?
<p>I am trying to create a reusable javascript object (I want to use new). When I attempt to new up one of my custom objects I get an error:</p>

<blockquote>
  <p>"org.myorg.sadp.section.sadpSection is not a constructor"</p>
</blockquote>

<p>I am modularizing my JS for namespace reasons. I wonder if that is the problem:</p>

<pre><code>if (!window.org) var org = { myorg: {} };    
if (!org.myorg) org["myorg"] = { sadp: {} };
if (!org.myorg.sadp) org.myorg["sadp"] = {};

org.myorg.sadp.section = (function(ns) {
    if (ns.section) {
        return ns;
    }
    else {
        ns.section = {};
    }
    ns.section.sadpSection = function(name) {
        this.name = name;
        this.isCompleted = false;
        this.booleanQuestions = new Array();
        this.multipleChoiceQuestions = new Array();
        this.sliders = new Array();
        return true;
    }
    return ns;

} (org.myorg.sadp))
</code></pre>

<p>This results in the error:</p>

<pre><code>var myObj = new  org.myorg.sadp.section.sadpSection("test");
</code></pre>

<p>What am I doing wrong here?</p>

<p>Thanks!</p>
