javascript定义类,并实例化的各类之间成员变量不干扰。
var foucs_a = { createNew: function(){ var cls = { id:'', cur:0, _init: function(id) { this.id = id; }, next: function() { alert(this.cur); this.cur++; } }; return cls; } }; var fa = foucs_a.createNew(); fa.next(); fa.next(); var fb = foucs_a.createNew(); fb.next(); fb.next();