var createScream = function(logger) {
return function(message) {
logger(message.toUpperCase() + "!!!")
}
}
const scream = createScream(message => console.log(message))
scream('functions can be returned from other functions')
Результат будет тот же, если написать:
var createScream = function(logger) {
return function(message) {
logger(message.toUpperCase() + "!!!")
}
}
const scream = createScream(console.log)
scream('functions can be returned from other functions')
Зачем в первом случае писать:
const scream = createScream(message => console.log(message))
Если можно:
const scream = createScream(console.log)