美文网首页
谷歌浏览器打印class对象

谷歌浏览器打印class对象

作者: storyWrite | 来源:发表于2022-02-11 17:11 被阅读0次

chrome的console 在 class 有get length 和 splice方法时, 使用console打印class的实例时会进入length方法,此时 this 为 class的prototype对象。

class A {
  splice(){}

  get length() {
    debugger;
    console.log(this === A.prototype);
    return 0;
  }
}

const a = new A();
console.log(a);

相关文章

网友评论

      本文标题:谷歌浏览器打印class对象

      本文链接:https://www.haomeiwen.com/subject/fjqzkrtx.html