Static variables in javascript

2015-05-15T06:16:00.000-07:00

myDemoObject = function(name) { this.demoname = name };
myDemoObject.options= new Array("country", "world","universe");
myDemoObject.prototype.options = myDemoObject.options;
myDemoObject.prototype.makeruler = function() {
   return this.demoname + " is the ruler of" +
         this.options[ Math.floor(
                         Math.random()*this.options.length
                      ) ] ;
}

mark = new myDemoObject("Mark Twain");
console.log(mark.makeruler());
console.log("But I wonder if he's the ruler of the"
             + myDemoObject.options[ Math.floor(
                Math.random()*myDemoObject.options.length
             ) ] );
myDemoObject.options= new Array("country", "world","universe");
myDemoObject.prototype.options = myDemoObject.options;