ES6 Concepts

In this example below you will see how to do a ES6 Concepts with some HTML / CSS and Javascript

ES6 concepts playground.

Thumbnail
This awesome code was written by izotope115, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright izotope115 ©
  • HTML
  • CSS
  • JavaScript
    

/*Downloaded from https://www.codeseek.co/izotope115/es6-concepts-apEgpW */
    


/*Downloaded from https://www.codeseek.co/izotope115/es6-concepts-apEgpW */
    //Template Literals
const myName = 'Gabe';
console.log(`My name is ${myName}`); //uses ticks rather than quotes to display template literal

//Spread Operation
const spread = [1, 2, 3, 4, 5];
console.log(...spread); //...spread will console log 1 2 3 4 5

// Argument Default Parameters
const fooFunction = (foo, bar = 10, baz = 'ES6 Rocks') => {
  console.log(foo, bar, baz);
}

fooFunction("Javascript"); //Javascript 10 ES6 Rocks

//Destructuring
const person = ["Gabe", "Mike", "Dave"];
console.log(person);//["Gabe", "Mike", "Dave"]

const newPerson = [0, ...person, 10];
console.log(newPerson);//[0, "Gabe", "Mike", "Dave", 10]

const [a, b, ...everything] = newPerson;
console.log(a, b, everything);//0 "Gabe" ["Mike", "Dave", 10]






Comments