const sayHello = (name) => console.log(`Hello ${name}`);
const sayHello2 = sayHello;
sayHello2('Shaun');
Hello Shaun

Conditionals

const myFunction = true //it is the parameter
? () => console.log('First option')
: () => console.log('Second option');
myFunction(true);
Hello Shaun
First option

An example of testing

const fetchDataReal = () => {
// time-intensive operations here!
};
const fetchDataFake = () => ({
name: 'John Doe',
age: 34,
});
const fetchData = DEVELOPMENT
? fetchDataFake
: fetchDataReal;

Array of functions

A list of functions executing as a routine

const double = (x) => x * 2;
const subtractOne = (x) => x - 1;
const triple = (x) => x * 3;
const add5 = (x) => x + 5;
const myNumber = 42;
const functionsArray = [
double,
subtractOne,
triple,
add5,
Math.sqrt,//no parenthesis. it is the function, not the result
];
let number = 42;
functionsArray.forEach((func) => number = func(number));
console.log(number);
15.937377450509228

Functions as arguments

1 function as argument:

const add = (x, y) => {
x + y; 
console.log(`Add = ${x + y}`);
};
const subtract = (x, y) => { 
x - y; 
console.log(`Substract = ${x - y}`); 
};
const combine2and3 = (func) => func(2, 3);
combine2and3(add); // -> 2 + 3
combine2and3((x, y) => x + y);
combine2and3(subtract); // -> 2 - 3
combine2and3(Math.max); // -> 3
Add = 5
Substract = -1

1 function and 1 parameter:

const add = (x, y) => {
x + y; 
console.log(`Add = ${x + y}`);
};
const subtract = (x, y) => { 
x - y; 
console.log(`Substract = ${x - y}`); 
};
const combine2and3 = (func, num = 99) => { 
console.log(`${num}`); 
func(2, 3);
};
combine2and3(add, 1); // -> 2 + 3
combine2and3((x, y) => x + y);
combine2and3(subtract, 3); // -> 2 - 3
combine2and3(Math.max, 4); // -> 3*/
1
Add = 5
99
3
Substract = -1
4

Returning functions

const createMultiplier = (y) => (x) => x * y;
const double = createMultiplier(2);
const triple = createMultiplier(3);
const quadruple = createMultiplier(4);
console.log(double(3));
console.log(triple(3));
console.log(quadruple(3));
6
9
12

Closure

It is the access to variables inside other functions

const createPrinter = () => {
const myFavoriteNumber = 42;
return () => console.log(`My favorite number is ${myFavoriteNumber}`);
};
const printer = createPrinter();
printer();
My favorite number is 42

Sources:
https://www.linkedin.com/learning/learning-functional-programming-with-javascript-es6-plus