var baz = {}; baz.Bar = function() { this.foo = function() { return 'Hello from BAZ.'; }; }; var moo = {}; moo.Bar = function() { }; moo.Bar.prototype.foo = function() { return 'Hello from MOO.'; }; $(function() { $('#run').click(function() { var b = new baz.Bar(); var m = new moo.Bar(); $('#debug').html( "b.toSource() => " + b.toSource() + "\n" + "m.toSource() => " + m.toSource() + "\n" + "b.foo() => " + b.foo() + "\n" + "m.foo() => " + m.foo() ); }); });
参考:JavaScriptの最適化について、code.google.comの記事の適当訳 - それ図解で。・・・tohokuaikiのチラシの裏
Let's make the web faster - Google Code
Copyright © 2009 Serendip. All rights reserved.