3 回答
TA贡献1850条经验 获得超11个赞
我不想这么说,但问题似乎定义不明确,但在这一点上,我只是建议使用“全局”变量。
const Scale = [ 0, 0 ];
function function1(param1, param2) {
// ...
// update Scale and return the array
return [
Scale[0] = Scale1,
Scale[1] = Scale2
];
}
function funtion2(paramA, paramB) {
// ...
// pray that function1 was called first, and use the results
const Q = Scale[0] * paramA;
const Z = Scale[1] * paramB;
}
TA贡献1798条经验 获得超7个赞
function fn1(param1,param2){
//do some confusing math
var Scale=[Scale1,Scale2];
return Scale
}
function fn2(scale_1,scale_2,paramA,paramB){
//some different stuff happens here, say:
var Q=scale_1*paramA;
var Z=scale_2*paramB;
}
fn2(...fn1(param1,param2), paramA,paramB)
TA贡献1998条经验 获得超6个赞
据我了解,您只需调用第一个函数并返回数据即可。然后将该数据传递给第二个函数。
function CalcScale(param1,param2){
//do some confusing math
return [Scale1,Scale2]
}
function processScale(scale_1,scale_2,paramA,paramB){
//some different stuff happens here, say:
var Q=scale_1*paramA;
var Z=scale_2*paramB;
}
scaling = CalcScale(param1,param2)
processScale(scaling[0],scaling[1],paramA,paramB)
添加回答
举报