请问是否正确

来源:6-4 编程练习

蛤小蛤

2019-11-10 19:19:57

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function animals(name, num) {
        this.name = name;
        this.num = num;
      }
      function cat() {}
      cat.prototype = new animals("cat", 8);
      cat.prototype.info = function() {
        alert(
          "动物名称:" + this.name + "\n" + "动物数量是:" + this.num + "只"
        );
      };
      var c = new cat();
      c.info();
    </script>
  </body>
</html>


写回答

1回答

好帮手慕夭夭

2019-11-11

同学你好,代码实现正确。继续加油,祝学习愉快~

0

0 学习 · 14456 问题

查看课程