1
2
3
4
5
6
7
8
9
10
11
var Book = function(title,price,type){
if(this instanceof Book){
this.title = title;
this.price = price;
this.type = type;
}else{
return new Book(title,price,type);
}
}

var book = Book('javascript','2014','js');