Created
November 5, 2019 08:13
-
-
Save hisasann/293088b9d4b2355dfd32f3ba17190da9 to your computer and use it in GitHub Desktop.
配列の分割代入とオブジェクトの分割代入
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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