title: Uncaught TypeError: Cannot set property 'getName' of undefined(anonymous function)
body: <pre><code> &lt;script&gt;  
      var Employee = new function(name)
      {
       this.name=name;
      }
      Employee.prototype.getName = function()
      {
        return this.name;
      }
  
      var PermanenetEmployee = new function(annualsalary)
      {
      this.annualsalary=annualsalary;
      }
      var employee = new Employee("rahul");
      PermanenetEmployee.prototype = employee;
      var pe = new PermanenetEmployee(5001);
      document.write(pe.getName());
  
  
  
      &lt;/script&gt; 
  </code></pre>
  
  <p>i am implementing inheritance in java script. From this code i want to print employee name like "rahul".But i am getting error in this like Uncaught TypeError: Cannot set property 'getName' of undefined(anonymous function).How to resolve this error?</p>
  
  <pre><code>Employee.prototype.getName = function()
          {
            return this.name;
          }
  </code></pre>