How to avoid multiple variable re-declarations on function outputs in JavaScript

前端 未结 6 1336
生来不讨喜
生来不讨喜 2021-01-24 16:37

Consider the following example

function doSomethingToAVariable(variable){
    return variable + 1
}

function doSomethingToAVariableASecondTime(variable){
    re         


        
6条回答
  •  梦谈多话
    2021-01-24 17:16

    Why not take a look at a functional approach with Ramda?

    R.compose(
      doSomethingToAVariableLastly,
      doSomethingToAVariableASecondTime,  
      doSomethingToAVariable
    )(myVariable)
    

提交回复
热议问题