Skip to content

Return multiple values

Important note: Check browser compatibilty for destructuring assignment. If you need to support older browsers, see the legacy example.

ECMAScript 6/2015 way

The returning of multiple values is basically just the returning of an object:

Legacy way

The legacy way just uses an array instead of an object:

[sc name=”src” url=”http://2ality.com/2014/06/es6-multiple-return-values.html” ]
[sc name=”src” url=”https://stackoverflow.com/questions/2917175/return-multiple-values-in-javascript” ]

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.