Operators
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
function isFullAge(...years){ years.forEach(cur=> (216-cur)>=18); } isFullAge(1990,1921,1967);