前端圣杯模式

it2025-02-09  11

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script type="text/javascript"> function Teacher(){} function Student(){} function Buffer(){} inherit(Student,Teacher); var s = new Student(); var t = new Teacher(); console.log(s); console.log(t); function inherit(Target, Origin){ function Buffer(){} Buffer.prototype = Origin.prototype; Target.prototype = new Buffer(); Buffer.prototype.constructor = Target; Buffer.prototype.super_class = Origin; } </script> </body> </html>
最新回复(0)