javascript function destructuring

JavaScript
const HIGH_TEMPERATURES = {
  yesterday: 75,
  today: 77,
  tomorrow: 80
};

//ES6 assignment syntax
const {today, tomorrow} = HIGH_TEMPERATURES;

//ES5 assignment syntax
const today = HIGH_TEMPERATURES.today;
const tomorrow = HIGH_TEMPERATURES.tomorrow;

console.log(today); // 77
console.log(tomorrow); // 80
console.log(yesterday); // "ReferenceError: yesterday is not defined" as it should be.let renseignement = ['voleur' , '10' , 'spécialité'] ;


let [classe , force, magie] = renseignement ;

console.log(classe) ;
console.log(force) ;
console.log(magie) ;const objA = {
 prop1: 'foo',
 prop2: {
   prop2a: 'bar',
   prop2b: 'baz',
 },
};

// Deconstruct nested props
const { prop1, prop2: { prop2a, prop2b } } = objA;

console.log(prop1);  // 'foo'
console.log(prop2a); // 'bar'
console.log(prop2b); // 'baz'function f() {
  return [1, 2];
}

let a, b; 
[a, b] = f(); 
console.log(a); // 1
console.log(b); // 2
// Taken from top stack overflow answer

const { dogName = 'snickers' } = { dogName: undefined }
console.log(dogName) // what will it be? 'snickers'!

const { dogName = 'snickers' } = { dogName: null }
console.log(dogName) // what will it be? null!

const { dogName = 'snickers' } = { dogName: false }
console.log(dogName) // what will it be? false!

const { dogName = 'snickers' } = { dogName: 0 }
console.log(dogName) // what will it be? 0!const { identifier } = expression;
Source

Also in JavaScript: