javascript中的类

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);

    }

  }

})()