js 闭包 定时器
; !function (win) { var tt1 = 10; //内部私有 , var tt2 = 20; //内部私有 //test.prototype.tt1 = 0;//共有变量 var test = function () {}; test.prototype.F1 = function (obj1,obj2) { } test.prototype.t1 = function (obj1, obj2) { console.log(obj1 + "test" + obj2); }; test.prototype.t2 = function (obj1,obj2) { var that = this; //var timeid = window.setInterval("mytest.t1(obj1,obj2)", 1000 * 2); //未定义 //var timeid = window.setInterval("mytest.t1('10','2')", 1000 * 2); //执行 //定时器 需要一个全局参数 var timeid = window.setInterval("mytest.t1(mytest.tt1,mytest.tt2)", 1000 * 2); //执行, } win.mytest = new test(); //继承 }(window); mytest.tt1 = 111; mytest.tt2 = 222; mytest.t2(15, 16); mytest.tt1 = 1110; mytest.tt2 = 2220;