Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Last active January 1, 2018 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinchisholm/02731479f9675b2dc31c4b7564ef8421 to your computer and use it in GitHub Desktop.
Save kevinchisholm/02731479f9675b2dc31c4b7564ef8421 to your computer and use it in GitHub Desktop.
var a, b;
[a, b] = ['foo', 'bar'];
console.log(a); // foo
console.log(b); // bar
var [a, b] = ['foo', 'bar'];
console.log(a); // foo
console.log(b); // bar
var [a, b, ...restOfArray] = ['foo', 'bar', 'monday', 'tuesday', 'wednesday'];
console.log(a); // foo
console.log(b); // bar
console.dir(restOfArray); // ['monday', 'tuesday', 'wednesday']
var {a, b} = {a: 'hello', b: 'godbye'};
console.log(a); // hello
console.log(b); // godbye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment