3 回答

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
我不想這么說(shuō),但問(wèn)題似乎定義不明確,但在這一點(diǎn)上,我只是建議使用“全局”變量。
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貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
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貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
據(jù)我了解,您只需調(diào)用第一個(gè)函數(shù)并返回?cái)?shù)據(jù)即可。然后將該數(shù)據(jù)傳遞給第二個(gè)函數(shù)。
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)
添加回答
舉報(bào)