请老师检查作业

来源:3-3 编程练习

鱼档卖鱼

2022-06-02 17:30:33

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8" />

    <title>Object.entries()</title>

</head>


<body>


    <script>

        /*

      function Person(name, age) {

          this.name = name;

          this.age = age;

          this.say = function() {

               console.log(this.name, this.age)

          }

      }

      Person.prototype.run = function() {

          console.log("run")

      }

      Person.intro = "this is a Person class"

      Person.show = function() {

          console.log('show')

      }

  */

        class Person {

            constructor(name, age) {

                this.name = name;

                this.age = age;

                this.say = function () {

                    console.log(this.name, this.age)

                }

            }

            run() {

                console.log("run")

            }

            static intro() {

                return "this is a Person class";

            }

            static show() {

                console.log('show')

            }

        }

        const xiaowang=new Person('xiaowang',21);

        xiaowang.say();

        xiaowang.run();

        console.log(Person.intro());

        Person.show();

    </script>

</body>


</html>


写回答

1回答

好帮手慕小李

2022-06-02

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

0

0 学习 · 17877 问题

查看课程

相似问题