Javascript 1.7 added destructuring assignment which allows you to do essentially what you are after.
function getTuple(){
return ["Bob", 24];
}
var [a, b] = getTuple();
// a === "bob" , b === 24 are both true
More Related Contents:
- One-liner to take some properties from object in ES 6
- What is destructuring assignment and its uses?
- Where can I get info on the object parameter syntax for JavaScript functions?
- Is it possible to destructure onto an existing object? (Javascript ES6)
- What does curly brackets in the `var { … } = …` statements do?
- ES6/ES2015 object destructuring and changing target variable
- How do I destructure all properties into the current scope/closure in ES2015?
- ES6 destructuring function parameter – naming root object
- How to destructure object properties with key names that are invalid variable names?
- Destructuring in Node.JS
- Destructuring and rename property
- ES6 Destructuring and Module imports
- Destructuring assignment in JavaScript
- Destructuring Nested objects in javascript | Destructure second level parent and child Objects
- ES6 destructuring object assignment function parameter default value
- What is the difference between const and const {} in JavaScript
- How can I ignore certain returned values from array destructuring?
- Array destructuring in JavaScript
- How to destructure option argument with all default values in ES6?
- Curly brackets (braces) in Node.js ‘require’ statement
- Destructure object properties inside array for all elements
- Node JS / V8 destructuring bug?
- Split a string straight into variables
- Destructuring of es6 but passing dynamic variable
- How to bind methods when destructuring an object in JavaScript?
- object destructuring: how to use intermediate nested property
- How to hide css and js version details from weppalyzer in PHP
- How to reset a form using jQuery with .reset() method
- Disable chrome react DevTools for production
- Passing a function with arguments as an argument?