es6 解构赋值

/*解构赋值*/

let book = {
  name: 'Learn Vue',
  year: 2020,
  title: 'Chapter one'
}
let { name } = book    // 这里不需要{...book}也可以

console.log(name);  // Learn Vue
console.log(book.name); // Learn Vue

name = 'new Learn'
console.log(name);  // new Learn
console.log(book.name); // Learn Vue
 

 

posted @ 2021-06-01 11:14  front-gl  阅读(45)  评论(0编辑  收藏  举报