0
0

JavaScript オブジェクトから特定のプロパティを変数へ取り出す方法

Posted at

JavaScript オブジェクトから特定のプロパティを変数へ取り出す方法

スプレッド構文と分割代入を応用すると、あるオブジェクトからほしい値だけを、変数代入することができる(学習メモ)

const profile = {
    name: 'taro',
    age: 27,
    address: 'tokyo'
};

const {address, ...other} = profile;
console.log (address);  // => tokyo
console.log (other);    // => {name: 'taro', age: 27}

0
0
0

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
0
0