Javascript:`newa()`vs`a()`-新操作符vs functioncall() var A=A()

Javascript:`newa()`vs`a()`-新操作符vs functioncall() var A=A(),javascript,object,properties,console,new-operator,Javascript,Object,Properties,Console,New Operator,以 在B 在C中 在D var A=newa() 以 在B 在C中 在D 在B 在C中 在D 谁能解释一下这是怎么回事吗 还有,关于我可以找到这些有趣问题的链接,有什么建议吗 提前谢谢:)这是一个可怕的构造函数调用示例。如果您想了解它们,请查找其他源。d中的回调在全局范围内运行,并调用全局a,而不是this.a。 function a() { this.a = function () { console.log("In A"); } this.b = fu


在B
在C中
在D

  • var A=newa()

  • 在B
    在C中
    在D
    在B
    在C中
    在D

    谁能解释一下这是怎么回事吗

    还有,关于我可以找到这些有趣问题的链接,有什么建议吗


    提前谢谢:)

    这是一个可怕的构造函数调用示例。如果您想了解它们,请查找其他源。
    d
    中的回调在全局范围内运行,并调用全局
    a
    ,而不是
    this.a
    function a() {
        this.a = function () {
            console.log("In A");
        }
        this.b = function () {
            console.log("In B");
        }
        this.c = function (cb) {
            console.log("In C ");
        }
        this.d = function (cb) {
            cb();
            console.log("In D");
        }
    
        this.d(function () {
            this.a();
            this.b();
            this.c();
        });
    }