ishehroze / angular-six-test

This repository contains angular 6 excercises for me and mohin bhai
https://ishehroze.github.io/angular-six-test/
0 stars 0 forks source link

2.6 Deconstructing #27

Open ishehroze opened 3 months ago

ishehroze commented 3 months ago

Remember Python's deconstruction:

a, b, c = (1, 2, 3)

However, EC2015 takes it to the next level:

obj = {first: 1, last: 100};

const {first, last} = obj;
console.log(first);  // 1
console.log(last);   // 100

const {first: f, last: l} = obj;
console.log(f);  // 1
console.log(l);  // 100

arr = [1, 2, 3];

const [a, b, c] = arr;
console.log(a);  // 1
console.log(b);  // 2
console.log(f);  // 3

However, the most useful part is the deconstruction of function parameters, particularly with default values:

function printSomething({something='Something'}) {
  console.log(something);
}

printSomething();
printSomething('Anything');
ishehroze commented 3 months ago

The lesson referred doesn't require any changes to this repository