Make javascript function and prototype definition in the same declaration?

Is it possible to combine this whole definition into one declaration and not break it down?

First part

var Pan = function(){};

The second part of

Pan.prototype = {

 //private variables
 Id: null,

 //public methods
 GetId: function(){
    alert(Id);
 }
}
+3
source share
1 answer

You can always do:

var Pan = function () {
    var Id = null;

    this.GetId = function(){
        alert(Id);
    }
};
0
source

All Articles