More ES6

02 Jan 2018

I have finished the Offline First course! So what’s left now is only the ES 6 updates (4 mini courses).

Template Literals

I’ve learnt what those backticks are. They are for template literals. (basically what I did with those silly madlib examples 2 days ago.) And what I did is called string interpolation

One of the improvements with template literals is you don’t need those bothersome newline characters ( \n ).

What you do instead:

      const name = 'Aurelie';
      const country = 'France';

      const message = `Hello,

      My name is ${name}.

      I live in ${country}.`;

      console.log(message);

output:

Hello,

My name is Aurelie.

I live in France.

Destructuring

This is totally new to me.

This is something you do with arrays and objects.

destructuring arrays

const positions = ['dog', 'cat', 'fish'];
const [first, second, third] = positions;
console.log(third); //fish

const days = [1, 2, 3, 4, 5, 6, 7];
const [monday, tuesday, wednesday, thursday] = days;
console.log(tuesday); //2