1. Use array
the let defaultColors = [ 'Red', 'Greed'] the let favoriteColors = [ 'Orange', 'Yellow'] the let fallColors = [ 'Pink', 'Blue'] the ES5 defaultColors.concat (favoriteColors) for ES6 [ defaultColors ..., ... favoriteColors] the ES5 defaultColors.concat (favoriteColors) defaultColors.concat (fallColors) for ES6 [... defaultColors, ... favoriteColors, ... fallColors] [ 'Purple', ... defaultColors, favoriteColors ..., ... fallColors, 'Black'] // can be placed directly in the array, may add another string
2. used in the function
ES5 function addNumber(a, b, c, d, e){ let numbers = [a, b, c, d, e] retrun numbers.reduce((sum, number) => { retrun sum + number },0) } console.log(addNumber(1,2,3,4,5)) ES6 function addNumber(...numbers){ retrun numbers.reduce((sum, number) => { retrun sum + number },0) } console.log(addNumber(1,2,3,4,5))
It recommended that the code in the editor view, would be more obvious