varBook=(function(){
//静态资源变量
var press="中央出版社";
//静态方法
var text=function(){};
function _book(id,content,name){
//私有属性
var name=press+"";
//私有方法
var checkBook=function(){
console.log(‘-------‘+name);
}
//特权方法
this.setContent=function(){};
this.getContent=function(){};
//公有属性
this.id=id;
this.setContent(content);
//共有方法
this.test=function(name){
console.log(‘--++++‘+press+name);
}
}
_book.prototype={
test2:function(){ console.log("prototype");}
}
return _book;
})();
var book=newBook(12,‘内容‘,‘名字‘);
console.log(book.id);
book.test(‘name‘);
book.test2();
console.log(Book.name);
原文:http://www.cnblogs.com/QQ-Monarch/p/7229159.html