Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created November 5, 2019 08:13
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 hisasann/293088b9d4b2355dfd32f3ba17190da9 to your computer and use it in GitHub Desktop.
Save hisasann/293088b9d4b2355dfd32f3ba17190da9 to your computer and use it in GitHub Desktop.
配列の分割代入とオブジェクトの分割代入
const array = ['foo'];
array.hoge = 'hoge';
// あくまでも配列の順番通りに変数が割り振られる
// foo という key を抜き取ってきているわけではない
const [ foo ] = array;
// hoge という key を取ってきている
const { hoge } = array;
console.log(foo); // foo
console.log(hoge); // hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment