1const book = {
2 title: 'Ego is the Enemy',
3 author: 'Ryan Holiday',
4 publisher: {
5 name: 'Penguin',
6 type: 'private'
7 }
8};
9
10const {title: bookName = 'Ego', author, name: {publisher: { name }} = book, type: {publisher: { type }} = book } = book;
1let renseignement = ['voleur' , '10' , 'spécialité'] ;
2
3
4let [classe , force, magie] = renseignement ;
5
6console.log(classe) ;
7console.log(force) ;
8console.log(magie) ;
1const hero = {
2 name: 'Batman',
3 realName: 'Bruce Wayne',
4 address: {
5 city: 'Gotham'
6 }
7};
8
9// Object destructuring:
10const { realName, address: { city } } = hero;
11city; // => 'Gotham'