eEhdsa

something interesting with prototype and window

1. 问题一

  var obj = {};
  function Con()
  {
  };
  Con.prototype = obj;
  var a =  new Con();
  document.writeln((a.prototype === Object.prototype.prototype).toString());  //true
  document.writeln((a.prototype === obj.prototype).toString());         //true
  document.writeln((obj.prototype == Object.prototype).toString());            //false
  document.writeln((obj.isPrototypeOf(a) && Object.prototype.isPrototypeOf(a)).toString());  //true
Object -> Object.prototype(Object.isPrototypeOf(Object))
obj -> Object.prototype.prototype(Object.prototype.isPrototypeOf(obj))
a -> obj.prototype === Object.prototype.prototype(Object.prototype.isPrototypeOf(a))
Function -> Object.prototype.prototype(Object.prototype.isPrototypeOf(Function))

2. 问题二 

IE 下专属问题


Why this returns a false?? what's more, window.window == window.window.window...this is true!!

window.window.window == window.window.window.window also returns true!!~~~what's the special in window? quite interesting~~

 

posted on 2009-12-22 23:42  eEhdsa  阅读(261)  评论(0编辑  收藏  举报

导航