本文为大家详细介绍下面向对象的继承以及如何实现批量实现面向对象感兴趣的可以参考下哈希望对大家有所帮助复制代码 代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf"> <title>批量实现面向对象的实例</title> <script type="text/javascript"> windowonload = function(){ function Person(nameage){ thisname = name; thisage = age; } PersonprototypeshowName = function(){ alert(thisname); }; function extend(parentchildmethod){ function a(){ parentapply(thisarguments); childapply(thisarguments); }; for(var i in parentprototype){ aprototype[i]=parentprototype[i]; } for(var i in method){ aprototype[i] = method[i]; } return a; };//参数为父级构造函数子级构造函数子级方法 var int = extend(Personfunction(nameagejob){ thisjob = job; } { showjob:function(){ alert(thisjob); } } ); var oc=new int(侠客工作); ocshowjob(); } </script> </head> <body> <h>面向对象继承实例</h> <p>开始展示批量实现面向对象的实例</p> </body> </html> |