一种无new创建对象的方法
2016-04-08 13:39 盛世游侠 阅读(209) 评论(0) 编辑 收藏 举报var L=function(){ var obj = { age:38, live:true, job:"web dev" }; obj.name = "zhouhui"; obj.__proto__ = L.prototype; return obj; }; L.prototype={ getName:function(){ console.log(this.name); }, getAge:function(){ console.log(this.age); }, getJob:function(){ console.log(this.job); } } var p = L(); console.log(p); console.log(p.getJob()); //web dev console.log(p instanceof L); //true