js问题辑录---return 返回链

2017-08-07  本文已影响0人  切磋琢磨_FE

1. 在一个function中返回另一个function的执行,会返回该函数还是返回该函数的执行结果?

function a(){
    return b();
}
function b(){
    return 'this is b';
}

a() //" this is b";

如果有很多函数连续return,会怎么样?

function a(){
    return b();
}
function b(){
    return c();
}
function c(){
    return d();
}
function d(){
    return "this is d";
}
a() // "this is d";

这样就形成了一个返回链,将多个function链起来了。

上一篇 下一篇

猜你喜欢

热点阅读