javascript - detect end of chained functions?

前端 未结 3 860

Today I\'m working on a pet project using chained function calls, and I\'m curious how I might detect when the last function in the chain is executed. For example:



        
3条回答
  •  时光取名叫无心
    2021-01-25 21:02

    You can't.

    Besides, if they are not chained:

    var v = func1('initial data');
    v = v.func2();
    v = v.func3();
    v = v.func4();
    

    What would you consider to be the last function? Every function is the last function in it's own chain, but if you finalise something after each step, that won't work.

    Just make a function that you call last to finalise the process.

提交回复
热议问题