Difference between revisions of "Operators"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
==Spread Operator == | ==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 == | |||
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]== | ==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Java Script|Category]]== |
Revision as of 20:11, 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