JavaScript (ECMAScript 6) の 分割代入 (Destructuring assignment)
簡単な例
1 2 3 4 5 6 7 |
const obj = {name:'Jane', age:18}; const {name:s, age:i} = obj; // s = 'Jane' ; i = 18 const {name, age} = obj; // name = 'Jane' ; age = 18 |
応用例
1 |
const {dialog} = require('electron').remote; |
以下のコードと等価
1 2 |
const remote = require('electron').remote; const dialog = remote.dialog; |