Operators

From rbachwiki
Revision as of 20:11, 2 December 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search

ES6 Spread Operator

ES6 Equivalent Spread Operator

const sum3 = addFourAges(...ages);
// the ... means the ages array is expanded into individual components.

Join two Arrays

const arrayOne= ['hello', 'two'];
const arrayTwo = ['three', 'four'];
const arrayThree = [...arrayOne, ...arrayTow];

Looping through all elements and changing the color

const h = document.querySelector(h1)
const boxes = documwnt.querySelectorAll('.box');
const all = [h, ...boxes];
Array.form(all).forEach(cur=> cur.style.color='purple') // returns an array

Rest Parameter

Back To Top- Home - Category