title: How to create Javascript Object using IIFE
body: <p>I have a Student object like the following,</p>
  
  <pre><code>function Student(){
        this.studentName = "";
  }
  Student.prototype.setStudentName=function(studentName){
        this.studentName = studentName;
  }
  Student.prototype.getStudentName=function(){
        return this.studentName;
  }
  </code></pre>
  
  <p>It works when I do <code>new Student();</code>. But If I create the same Object like the following it gives an error,</p>
  
  <pre><code>(function(){
  
      function Student(){
            this.studentName = "";
      }
      Student.prototype.setStudentName=function(studentName){
            this.studentName = studentName;
      }
      Student.prototype.getStudentName=function(){
            return this.studentName;
      }
              })();
  </code></pre>
  
  <p>When I alert <code>new Student()</code>, I am getting an error <code>Student is not defined</code>.
  I tried writing <code>return new Student()</code> inside IIFE but didn't work for that also. How can I create Javascript objects using IIFE? </p>