new function() { // private static fields var s_first = 1; var s_second = 2; // private static methods function s_method1() { s_first++; } var s_second = 2; class6 = function() { // private fields var m_first = 1; var m_second = 2; // private methods function method1() { alert(m_first); } var method2 = function() { alert(m_second); } // public fields this.first = "first"; this.second = ['s','e','c','o','n','d']; // public methods this.method1 = function() { s_second--; } this.method2 = function() { alert(this.second); } // constructor { s_method1(); this.method1(); } } // public static methods class6.method1 = function() { s_first++; alert(s_first); } class6.method2 = function() { alert(s_second); } }; var o1 = new class6(); class6.method1(); class6.method2(); o1.method2(); var o2 = new class6(); class6.method1(); class6.method2(); o2.method2();
class7 = new function() { // private static fields var s_first = 1; var s_second = 2; // private static method function method1() { alert(s_first); } // public static method this.method1 = function() { method1(); alert(s_second); } } class7.method1();
|