Skip to content

Instantly share code, notes, and snippets.

@claudioovp
Last active September 18, 2019 12:22
Show Gist options
  • Select an option

  • Save claudioovp/0eb76e33df781485b195134005ade411 to your computer and use it in GitHub Desktop.

Select an option

Save claudioovp/0eb76e33df781485b195134005ade411 to your computer and use it in GitHub Desktop.
ES6 Tips
// can destructure arrays
const [a, b] = [1,2]; // a = 1, b = 2
// can destructure object keys
const { a } = { a: 3 }; // a = 3
var a, b, rest;
[a, b] = [1, 2];
console.log(a); // 1
console.log(b); // 2
[a, b, ...rest] = [1, 2, 3, 4, 5];
console.log(a); // 1
console.log(b); // 2
console.log(rest); // [3, 4, 5]
({a, b} = {a:1, b:2});
console.log(a); // 1
console.log(b); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment