Return multiple values in JavaScript?

I am trying to return two values in JavaScript. Is this possible? var newCodes = function() { var dCodes = fg.codecsCodes.rs; var dCodes2 = fg.codecsCodes2.rs; return dCodes, dCodes2; }; 20 s 20 No, but you could return an array containing your values: function getValues() { return [getFirstValue(), getSecondValue()]; } Then you can access them like … Read more

Best way to return multiple values from a function? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. Improve this question The canonical way to return multiple values in languages that support it is often tupling. Option: … Read more

Returning null in a method whose signature says return int?

int is a primitive, null is not a value that it can take on. You could change the method return type to return java.lang.Integer and then you can return null, and existing code that returns int will get autoboxed. Nulls are assigned only to reference types, it means the reference doesn’t point to anything. Primitives are not reference … Read more