当前位置: 代码迷 >> Web前端 >> prototype有关测试代码
  详细解决方案

prototype有关测试代码

热度:240   发布时间:2013-11-08 17:52:32.0
prototype相关测试代码
  function A () {
      this.foo = function () {}
  }
  A.prototype.bar = function () {}
  function B(){}
  B.prototype = new A();

  var a = new A();
  var b = new B()
  console.log(b.__proto__===B.prototype)    // true
  console.log(b.foo===a.foo)                // false
  console.log(b.bar===a.bar)                // true
  console.log(B.prototype===A.prototype)    // false

?

  相关解决方案