Difference between revisions of "Operators"

From rbachwiki
Jump to navigation Jump to search
Line 16: Line 16:


== Rest Parameter ==
== Rest Parameter ==
function isFullAge(...years){
years.forEach(cur=> (216-cur)>=18);
}
  isFullAge(1990,1921,1967);




==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]==
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]==

Revision as of 22:17, 2 December 2016

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);


Back To Top- Home - Category