functionMyObject(name,message){this.name=name.toString();this.message=message.toString();}MyObject.prototype={getName:function(){returnthis.name;},getMessage:function(){returnthis.message;}};和functionMyObject(name,message){this.name=name.toString();this.message=message.toString();}MyObject.prototype.getName=function(){returnthis.name;};MyObject.prototype.getMessage=function(){returnthis.message;};代码中的下面2段有什么区别?哪种写法比较好一些?MyObject.prototype={getName:function(){returnthis.name;},getMessage:function(){returnthis.message;}};和MyObject.prototype.getName=function(){returnthis.name;};MyObject.prototype.getMessage=function(){returnthis.message;};各位麻烦帮我解答下,不是很懂..谢谢
添加回答
举报
0/150
提交
取消