14.原型式继承.html 601 B

12345678910111213141516171819202122232425262728
  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>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let Father = {
  11. name: '图图',
  12. age: 3,
  13. list: ['吃饭', '睡觉', '打豆豆'],
  14. say() {
  15. console.log("你好")
  16. }
  17. }
  18. let c1 = Object.create(Father);
  19. let c2 = Object.create(Father);
  20. c1.list.push("99")
  21. console.log(c1,'c1')
  22. console.log(c2,'c2')
  23. </script>
  24. </body>
  25. </html>