Skip to content
JS Fundamentals: Objects, Arrays, and Functions
Share
Explore
Functions

icon picker
Higher Order Functions / Callbacks

Higher order functions are functions that can take a function as an input to a function or return a function from another function. We’ve been doing this quite a bit in this workshop so far. Take a look at some examples below:
element.addEventListener("change", () => {
console.log("Our evidence is updated");
});

const newClue = (name) => {
const length = name.length;
return (weapon) => {
const clue = length + weapon.length;
return !!(clue % 1);
};

};
Read more about HOF

Arrow Functions

You may notice above and in some of our examples, we are using arrow functions, () => {}. As of ES2015 (aka ES6), an arrow function expression is a compact alternative to a traditional function expression, but is limited and can't be used in all situations. They are particularly useful when used as callbacks!
What are the limitations of an arrow function?
Doesn’t have it’s own keyword this , it just looks up the context of the parent scope
Anonymous
Read more about arrow functions

Next 👉


©2021 for
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.