2010年12月18日
摘要: var obj = new fn();创建对象的过程分三步1.创建一个新对象{}2.{}._proto_=fn.prototype;3.fn.call({});js是基于原型的继承。那么我们能否自己定义一个对象当作原型,然后将这个自己创建的原型设置给一个对象,那么这个对象不就继承的原型的所有方法和属性?演化过程1:var myprototype = {  sayHello:function(){    alert("hello "+this.name);  }}function f(name){//扮演构造函数  this.name = name;}f.prototype = myprotot 阅读全文
posted @ 2010-12-18 03:22 fire8119 阅读(198) 评论(0) 推荐(0)
  2010年11月20日
摘要: http://dean.edwards.name/weblog/2006/03/base/按照自己理解翻译的(超烂),只为自己而写。I’m an OO programmer at heart and JavaScript supports prototype based inheritance. Unfortunatley this leads to verbose class def... 阅读全文
posted @ 2010-11-20 17:08 fire8119 阅读(377) 评论(0) 推荐(0)