fork download
  1. var Gadget = (function () {
  2. // 静态变量/属性
  3. var counter = 0,
  4. NewGadget;
  5.  
  6. //新构造函数实现
  7. NewGadget = function () {
  8. counter += 1;
  9. };
  10.  
  11. // 授权可以访问的方法
  12. NewGadget.prototype.getLastId = function () {
  13. return counter;
  14. };
  15.  
  16. // 覆盖构造函数
  17. return NewGadget;
  18. } ()); // 立即执行
Success #stdin #stdout 0.27s 213248KB
stdin
Standard input is empty
stdout
Standard output is empty