-
Notifications
You must be signed in to change notification settings - Fork 0
HOF
SimonPlanje edited this page Jun 9, 2020
·
1 revision
Functions are values
function triple (x) {
return x * 3;
}
but not all programming languages can do this
var triple = function(x) {
return x * 3;
}
The function gets assigned to a value, now the value can be used again and again all over the JS page
var waffle = triple
console.log(waffle(30))
//90
Functions can be passed into values but also in to OTHER functions these are called Higher Order Functions
var animals = [
{ name: "henk", species: "rabbit"},
{ name: "joost", species: "dog"},
{ name: "frank", species: "dog"},
{ name: "koos", species: "fish"},
]
Simon Planje 20/06/2020
