我试图在JavaScript中返回两个值。这有可能吗?var newCodes = function() {
var dCodes = fg.codecsCodes.rs;
var dCodes2 = fg.codecsCodes2.rs;
return dCodes, dCodes2;};
3 回答
眼眸繁星
TA贡献1873条经验 获得超9个赞
function getValues() { return [getFirstValue(), getSecondValue()];}
var values = getValues();var first = values[0];var second = values[1];
const [first, second] = getValues();
function getValues() { return { first: getFirstValue(), second: getSecondValue(), };}
var values = getValues();var first = values.first;var second = values.second;
const {first, second} = getValues();
慕桂英546537
TA贡献1848条经验 获得超10个赞
var [x, y] = [1, 2];x; // 1y; // 2// or[x, y] = (function(){ return [3, 4]; })();x; // 3y; // 4
let {baz, foo} = (function(){ return {foo: 3, bar: 500, baz: 40} })();baz; // 40foo; // 3
return 1, 2, ...
1, 2, 3
1
, 2
3
3
return 1, 2, 3
return 3
.
return 1, 2, 3;// becomesreturn 2, 3;// becomesreturn 3;
添加回答
举报
0/150
提交
取消