Is calling a function that returns a function with new different than just invoking it normally?

前端 未结 3 1800
南旧
南旧 2021-01-21 21:51

So let\'s say I have a javascript function

function A(){
    return function(){
        console.log(\'something\');
        return new B();
    }
}
3条回答
  •  误落风尘
    2021-01-21 22:22

    Since that function has an explicit return and makes no use of this, there is no difference in the result of running it with or without new.

提交回复
热议问题