ES5
var Book=(function () {
var bookNum=0;
function checkBook(name){}
function _Book(newId,newName,newPrice){
this.getName=function () { return newName};
this.getPrice=function () { return newPrice};
}
_Book.prototype={
isJSBook:false,
dispaly:function () {}
}
_Book.author="hyylsw";
return _Book;
})();
var book=new Book(1,"js",12.4);
console.log(book.getName());
console.log(book.getPrice());
console.log(book.isJSBook);
ES6
class Book2{
constructor(newId,newName,newPrice){
this.id=newId;
this.name=newName;
this.price=newPrice;
}
display(){}
}
let book2=new Book2(1,"java",12.3);
console.log(book2.name);