June 2018
Beginner
288 pages
6h 31m
English
Here are the solutions to the Exercises, for the Chapter 5, Arrow Functions and Functional Style chapter.
For anonymous functions, this and arguments are dynamically scoped and other non-local, non-parameter variables are lexically scoped.
For arrow functions, all non-local, non-parameter variables are lexically scoped.
Here’s a solution to make the code concise and to use arrow functions:
| | 'use strict'; |
| | |
| | const success = value => ({ value: value }); |
| | |
| | const blowup = value => { throw new Error('blowing up with value ' + value); }; |
| | |
| | const process = function(successFn, errorFn) { |
| | const value = Math.round(Math.random() * 100, 2); |
| | |
| | return value > 50 ? successFn(value) : errorFn(value); ... |
Read now
Unlock full access