1 function Container(properties) {
 2             for (var property in properties) {
 3                 (function () {
 4                     var item = properties[property];
 5                     this["get" + property] = function () { return item; };
 6                     this["set" + property] = function (val) { item = val; };
 7                 }).call(this);
 8             }
 9 }
10 
11         var prop = { Name: "Jim", Age: 13 };
12         var con = new Container(prop);
13         console.log(con.getName());
14         console.log(con.getAge());

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-07-19
猜你喜欢
  • 2021-09-18
  • 2021-12-02
  • 2021-08-01
  • 2022-12-23
相关资源
相似解决方案