var Book = (function(){

  // 静态私有变量

  var bookNum = 0;

  // 静态私有方法

  function checkBook(){}

  // 创建类

  function _book(newId, newName, newPrice) {

    if (this instanceof Book) {

      // 私有变量

      var name, price;

      // 私有方法

      function checkId(){}

      // 特权方法

      this.getName = function(){}

      bookNum++;

      if(bookNum > 100) {}

 

      // 构建原型

      _book.prototype = {

        isJSBook: false,

      }

 

      return _book;

    } else {

      return new Book(newId, newName, newPrice);

    }

  }

})()

相关文章:

  • 2022-12-23
  • 2021-04-06
  • 2021-05-31
  • 2021-07-28
  • 2021-08-23
  • 2021-06-03
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2021-09-12
  • 2021-12-03
  • 2021-09-06
相关资源
相似解决方案