title: Protractor Page Object using constructor
body: <p>I have spec like this:</p>
  
  <pre><code>describe('test', function() {
  function CreateApple(type,color, width){
      this.type= type
      this.color=color;
      this.width=width;
  }
  
  CreateApple.prototype.eat= function(){
      return console.log("eat mniam, mniam");
  }
  
  CreateApple.prototype.height = 55;      
  
  CreateApple.prototype.xxx={
          module1:  1,
          hhh: 2,
  
          tablice:{
              tab1: function(num){return num},
              tab2: 44,
          }
  }
  
  it('test1', function() {
  
  
      var apple1 = new CreateApple("goodone", "red", 34);
      apple1.eat();
          console.log(apple1.type);
          console.log(apple1.height);
          var ttt= apple1.xxx.hhh;
          var uuu= apple1.xxx.tablice.tab1(4);
          console.log(ttt+" "+uuu);
  
      });
  });
  </code></pre>
  
  <p>When I run it using my conf.js everything works excellent. Now I would like to use Page Object and leave in my spec.js only 'test1' which means that constructor 'CreateApple' and its prototypes shoud go to the other file. Can anyone tell me how my new 'page object' file should look like?? I got something like below but I doesnt work:</p>
  
  <p>spec.js</p>
  
  <pre><code>require('../jgh/page4.js');
  
  describe('test', function() {
  
  it('test1', function() {
  
  var apple1 = new CreateApple("goodone", "red", 34);
  apple1.eat();
      console.log(apple1.type);
      console.log(apple1.height);
      var ttt= apple1.xxx.hhh;
      var uuu= apple1.xxx.tablice.tab1(4);
      console.log(ttt+" "+uuu);
  
  });
  });
  </code></pre>
  
  <p>and my page4.js</p>
  
  <pre><code>modules.exports =function CreateApple(type,color, width){
      this.type= type
      this.color=color;
      this.width=width;
  }
  
  CreateApple.prototype.eat= function(){
      return console.log("eat mniam, mniam");
  }
  
  CreateApple.prototype.height = 55;      
  
  CreateApple.prototype.xxx={
         module1:  1,
         hhh: 2,
  
         tablice:{
             tab1: function(num){return num},
             tab2: 44,
          }
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Error: ReferenceError: CreateApple is not defined
  </code></pre>