Skip to content
SimonPlanje edited this page Jun 9, 2020 · 1 revision

Higher order functions

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"},

]

Clone this wiki locally