LoginSignup
2
1

More than 5 years have passed since last update.

javascript ES6 {} で変数にオブジェクトを代入する書き方

Last updated at Posted at 2019-04-16
const obj = {
  a:1,
  b:2,
  c: {cc:3}
}
//分割代入。オブジェクトのプロパティを指定してあげる
const {b, c} = obj;


console.log(b) // 2
console.log(c); // {cc:3}
console.log(d); //d is not defined

分割代入というES6での新しい書き方。
慣れないうちは違和感を覚えたので簡単にメモ。

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1