js动态创建类对象
1.定义函数,函数中定义类对象 f1=function(){ //定义类 function Pannel(name){ this.name = name; this.print = function(){ console.info(this.name); }; } //扩展类方法成员 Pannel.prototype.show = function(){ alert(this.name); } //返回类 return Pannel; } 2.执行函数,获得类 Pannel = f1(); 3.调用类,new出对象 var pannel = new Pannel("张三"); console.info(pannel.name); pannel.print(); pannel.show();