title: Use constructor function execute prototype methods structure
body: <pre><code>(function($){
      'use strict';
  
      var ezAutoSuggestion = function( selector, href ){
          return new init(selector, href);
      };
  
      //construct
      var init = function( selector, href ){
  
          defaults.call(this);
  
          //property
          this.element = $(selector);
          this.href = href;
          this.inputText = $(selector + " input[type='text']" );
          this.inputText.after(this.suggestionList);
          this.list = $(selector + " ul");
          this.choosen = selector + " li";
  
          //method    
          this.getDatas();
          this.hideList();    
          this.choose();  
      };
  
      //method
      init.prototype.getDatas = function(){
          //post input keyup value and get data from backend
      };
  
      init.prototype.choose = function(){
          //add user's choose into input text
      };
  
      init.prototype.hideList = function(){
          //user click blank area hide auto suggestion
      };
  
      window.ezAutoSuggestion = ezAutoSuggestion;
  
  })(jQuery);
  </code></pre>
  
  <p>I'm new in writing javascript plugin, I wrote a simple auto suggestion plugin and I have put on github MIT licence for people to download it.</p>
  
  <p>My question is</p>
  
  <p>First I create a <code>construct function,</code> and inside of my constructor I set up <code>properties</code> and than <code>start call methods</code>. (I also borrow jQuery's idea user function to create a <code>new init object</code>, so user don't need to type new)</p>
  
  <p>Is this good way to do? or are any better way to structure this?</p>
  
  <p>here is my github links
  <a href="https://github.com/yben56/ez-auto-suggestion" rel="nofollow noreferrer">https://github.com/yben56/ez-auto-suggestion</a></p>