- Describe the purpose of Babel and when it should be used
- Concatenate strings and variables with template strings
- Declare variables with only let and const
- Write anonymous functions with arrow functions
- Declare defaults to functions parameters
- Declare object literals with new shorthand
- Destructure arrays and objects to assign values
- Write dynamic code with the rest and spread operators
-
Update the following code to use ES6 features:
var winners = [ 'Otis Duncan', 'Melba Frank', 'Damon Adams' ] function printWinnersByPlace (people) { var first = winners[0] var rest = winners.slice(1) return 'In 1st place is ' + first + '! Followed up by ' + rest.join(' and ') + '.' } printWinnersByPlace(winners)
-
Update the following code to be terser and use ES6 features:
function orderBy (array, key, options) { options = options || {} var toSort = array.slice() if (options.asc) { toSort.sort(function (a, b) { return a[key] > b[key] ? 1 : -1 }) } if (options.desc) { toSort.sort(function (a, b) { return a[key] < b[key] ? 1 : -1 }) } return toSort } const people = [ { firstName: 'Dustin', lastName: 'French', age: 23 }, { firstName: 'Norman', lastName: 'Sanders', age: 44 }, { firstName: 'Jessica', lastName: 'Glover', age: 39 }, { firstName: 'Alfred', lastName: 'Hicks', age: 31 } ] orderBy(people, 'lastName', { desc: true })