const foo = () => {
console.log("foobar");
};
foo(); // Invoke it using the variable
// foobarFirst-class function / notebook
First-class function
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
function sayHello() {
return "Hello, ";
}
function greeting(helloMessage, name) {
console.log(helloMessage() + name);
}
// Pass `sayHello` as an argument to `greeting` function
greeting(sayHello, "JavaScript!");
// Hello, JavaScript!function sayHello() {
return () => {
console.log("Hello!");
};
}