title: Javascript instance context prototype
body: <p>Sorry for not so good topic title. Don't know how to name it.</p>
  
  <p>I need a help with this example, I'm totaly lost.</p>
  
  <p>So when function fillView called it's all good, but second time when its called on re-size it just doesn't work, because  inside render functions 'this' defines a Window, but not a instance of localClass. I need a explanation how to figure out this problem. Please write a example.</p>
  
  <pre><code>(function ($) { 
  var localClass = function(options) {
      this.a = 123;
  };
  
  localClass.prototype.render = function() {
      console.log(this.a);
  }
  
  $.fn.fillView = function(options){
      var view = new localClass(options);
      view.render(); //this prints to console 123
  
      $(window).resize(view.render); //this doesn't print 123 
                                       because 'this' is now - Window
  
      }
  })(jQuery)
  </code></pre>