2017-06-16 14 views
-1

2つの関数の結果を返そうとしていますが、成功しません。私は、次のことをやっている:JavaScript内の複数の関数の結果を返す

var x = getFunctionResults1(items); 
var y = getFunctionResults2(items); 
return {x,y} 

しかし、この出力を得る:

[ { x: [ [Object], [Object], [Object], [Object], [Object] ], 
    y: [ [Object] ] }, 
    { x: [ [Object], [Object] ], y: [ [Object] ] } ] 

答えて

1

あなたは

return [getFunctionResults1(functionResults1), getFunctionResults2(functionResults2)]; 

かのオブジェクトを使用するように、二つの機能のために結果オブジェクトとして配列を使用することができますキー付きパーツ、

return { 
    result1: getFunctionResults1(functionResults1), 
    result2: getFunctionResults2(functionResults2)] 
}; 
関連する問題