2013年11月3日

关于function中存在return语句时,使用new关键字的问题

摘要: 现在流行创建对象的时候不使用new关键字,即使用function中return的形式返回对象。这样消除了忘记使用new关键字而造成的调试错误的隐患。1 function testObject(){2 this.a = "hello";3 this.b = {abc:"hello",cba:"olleh"};4 return b;5 }6 7 var test001 = testObject(); 从而能使用 var test01 = testObject()获得返回的对象。但是有一个疑问,带有return的function继续使用ne 阅读全文

posted @ 2013-11-03 21:06 wenlonghor 阅读(222) 评论(0) 推荐(0) 编辑

导航