麻烦老师看下这样正确吗

来源:5-4 编程练习

艾丶

2020-04-13 22:53:38

<!DOCTYPE html>

<html lang="en">


<head>

  <meta charset="UTF-8">

  <title>5-4</title>

</head>


<body>

  <script>

    //补充代码 

    function Student() {

      privateStore = {};

      function _get() {

        return this.privateStore;

      }

      function _set(privateStore) {

        this.privateStore = privateStore;

      }

    }


    Student.prototype.get = function () {

      return this.privateStore;

    }

    Student.prototype.set = function (privateStore) {

      this.privateStore = privateStore;

    }


    var student = new Student();

    student.set({

      name: '张宇',

      sex: '男',

      age: 18

    })

    console.log(student.get());



  </script>

</body>


</html>


写回答

1回答

好帮手慕粉

2020-04-14

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

0

0 学习 · 14456 问题

查看课程