Return multiple values in JavaScript?

前端 未结 20 2008
暖寄归人
暖寄归人 2020-11-22 13:17

I am trying to return two values in JavaScript. Is this possible?

var newCodes = function() {  
    var dCodes = fg.codecsCodes.rs;
    va         


        
20条回答
  •  长发绾君心
    2020-11-22 14:06

    Well we can not exactly do what your trying. But something likely to below can be done.

    function multiReturnValues(){
        return {x:10,y:20};
    }
    

    Then when calling the method

    const {x,y} = multiReturnValues();
    
    console.log(x) ---> 10
    console.log(y) ---> 20
    

提交回复
热议问题