经常会看到a如何继承b的问题决定写一下其实继承就是继承父级的属性和方法感兴趣的朋友可以参考下哈希望对大家有所帮助复制代码 代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf"> <title>面向对象继承实例</title> <script type="text/javascript"> windowonload = function(){ function parent(agename){ thisage = age; thisname = name; } parentprototypeshow = function(){ alert(父级方法); } function child(agenamejob){ parentapply(thisarguments); thisjob = job; } (function(){ for(var i in parentprototype){ childprototype[i]=parentprototype[i] } })();
var b = new parent(侠客行); var a = new child(狼侠侠客); ashow();
} </script> </head> <body> <h>面向对象继承实例</h> <p>经常看到面试题有关继承问题 a如何继承b 决定写一下其实继承就是继承父级的属性和方法</p> </body> </html> |