| 1234567891011121314151617181920212223242526272829303132 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>原型链继承</title>
- </head>
- <body>
- <script>
- function Father() {
- this.name = 'Lucy';
- this.arr = [1, 2, 3];
- }
- function Child() {
- this.age = 10;
- }
- Child.prototype = new Father();
- const c1 = new Child();
- const c2 = new Child();
- c1.age = 18;
- c1.name = '图图'
- c1.arr.push('00')
- console.log(c1, 'c1')
- console.log(c2, 'c2')
- </script>
- </body>
- </html>
|