Functions.

Function Declaration

helloWorld();

function helloWorld() {
  alert("Hello world!");
}

Function Expression

const helloWorld = function () {
  alert("Hello world!");
};

helloWorld();

How passing arguments works: value vs reference

const directionOne = "Amsterdam";
const passengerOne = {
  name: "Mark Test",
  passport: 123456789,
};

const checkIn = function (direction, passenger) {
  direction = "Paris";
  passenger.name = "Mr." + passenger.name;
};

checkIn(directionOne, passengerOne);
console.log(directionOne);
console.log(passengerOne);
Higher-order functions — a function that receives another function as an argument, that returns a new function, or both.

Immediately invoked function expressions

(function () {
  console.log("Lorem ipsum dolor sit amet, consectetur adipiscing elit");
})();