I am very new to coding javascript plugin and i have in the last half year or so build about 2 plugins of my own, basically gallery plugins for my own personal use. now i usually use the following pattern in an IFFE.
$.Mypluginname = function() {
    this.anotherfunction(); // works !! 
}
$.mypluginname.prototype.anotherfunction(){
     // this points to $.Mypluginname awesome!!!
}
$.mypluginname.prototype.anotherfunction(){
    // this points to $.Mypluginname awesome!!!
}
But recently i have found a better JS plugin pattern, It looks like so,
$.Mypluginname = function() {
}
$.mypluginname.prototype = {
   anotherfunction : function(){
     // this points to $.Mypluginname awesome!!!  ... but how ? 
   }
   mypluginname : anotherfunction(){
    // this points to $.Mypluginname awesome!!!  ... but how ? 
   }
}
See how this still points to the main function, My question really is how ?
how is the this inside the below function:
$.Mypluginname = function() {
          this.anotherfunction(); // works !! ... can you answer this quinten.
    }
?
Can anybody explain ?
EDIT :: There are 12 answers in this thread. none of which answer my question , which was not "how does prototype work" in the first place. reading that thread will certainly enhance my knowledge of JS prototype , but i don't see how it would explain how this works in the below design pattern.
$.mypluginname.prototype = {
       anotherfunction : function(){
         // this points to $.Mypluginname awesome!!!  ... but how ? 
       }
       mypluginname : anotherfunction(){
        // this points to $.Mypluginname awesome!!!  ... but how ? 
       }
    } 
Thank you.
Alex-z.
 
     
     
     
    