Static self member in javascript -
possible duplicate:
static variables in javascript
how can make static encapsulation self members in javascript? such in php:
class bar{ static public $foo; static public function set() { self::$foo = 'a'; } } bar::set(); in javascript: var bar = function () { ???????? } bar.set();
thanks!
simply define them properties of bar.
bar.foo = null; bar.set = function() { bar.foo = "a"; } here's nice overview:
var bar = function() { // private instance variables var = 1; // public instance variables this.b = 5; // privileged instance methods this.c = function() { return a; } }; // public instance methods bar.prototype.d = function() { return ++this.b; } // public static variables bar.foo = null; // public static methods bar.set = function() { bar.foo = "a"; }
Comments
Post a Comment