调用一个函数返回一个新的函数而不仅仅是正常调用它? [英] Is calling a function that returns a function with new different than just invoking it normally?
本文介绍了调用一个函数返回一个新的函数而不仅仅是正常调用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以假设我有一个javascript函数
So let's say I have a javascript function
function A(){
return function(){
console.log('something');
return new B();
}
}
使用 new调用此方法A();
任何不同于 A();
?
推荐答案
由于该函数有一个显式的 return
而且没有使用这个
,所以没有使用或不使用 new
运行结果的差异。
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
.
这篇关于调用一个函数返回一个新的函数而不仅仅是正常调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文