| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <!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>
- function Father(address1) {
- this.name = '图图';
- this.list = [1,2,3];
- this.address = address1;
- }
- Father.prototype.say = function () {
- console.log("你好")
- }
- function Child(address1) {
- Father.call(this,address1);
- this.age = 3;
- }
- // Child.prototype = new Father();
- function createObj(c, f) {
- c.prototype = Object.create(f.prototype);
- c.prototype.constructor = c;
- }
- createObj(Child, Father);
- let c1 = new Child('上海');
- let c2 = new Child('哈尔滨');
- c1.list.push("你好")
- console.log(c1)
- console.log(c2)
- </script>
- </body>
- </html>
|