作者kevintwo (MAI舞)
看板Ajax
标题[问题] closure 和 prototype的差别~
时间Tue Jun 2 22:59:56 2009
(问题一)
在这个网页==>
http://caterpillar.onlyfun.net/Gossip/AjaxGossip/ConstructorPrototype.html
里提到的 getSize 的建立方式分别为closure 和 prototype的方式
请问差别在哪呢? 不知怎麽理解^^"
是记忆体的占用方式有差吗?还是?
(问题二)
在犀牛书上看到的
function Rectangle(w,h) {
this.width = w;
this.height = h;
this.area = function() { return this.width*this.height;}
}
和
function Rectangle(w,h) {
this.width = w;
this.height = h;
}
Rectangle.protoype.area = function() { return this.width* this.height; }
这两种的area差别要怎麽看呢?
烦请各位前贤讲解一下了<(_ _)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.95.110
※ 编辑: kevintwo 来自: 140.113.95.110 (06/03 11:14)
※ 编辑: kevintwo 来自: 140.113.95.110 (06/03 11:19)