Skip to content

Instantly share code, notes, and snippets.

@mbrookson
Last active July 3, 2020 09:43
Show Gist options
  • Save mbrookson/068cb7957a1fd8043ea500923c0013e1 to your computer and use it in GitHub Desktop.
Save mbrookson/068cb7957a1fd8043ea500923c0013e1 to your computer and use it in GitHub Desktop.
JavaScript destructuring
function person() {
return { name: 'Matt', age: 25 };
}
// Object destructuring
let { name, age } = person();
// name === 'Matt'
// age === 25
// Array destructuring
let [item1, item2] = [1, 2, 3, 4];
// item1 === 1
// item2 === 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment