1.html 645 B

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>原型链继承</title>
  7. </head>
  8. <body>
  9. <script>
  10. function Father() {
  11. this.name = 'Lucy';
  12. this.arr = [1, 2, 3];
  13. }
  14. function Child() {
  15. this.age = 10;
  16. }
  17. Child.prototype = new Father();
  18. const c1 = new Child();
  19. const c2 = new Child();
  20. c1.age = 18;
  21. c1.name = '图图'
  22. c1.arr.push('00')
  23. console.log(c1, 'c1')
  24. console.log(c2, 'c2')
  25. </script>
  26. </body>
  27. </html>