Skip to main content

Ways to Write Functions

Function Declaration

function hello() {
console.log("Hello, world!");
}

It can be used before it is defined.

Function Expression

const hello = function () {
console.log("Hello, world!");
};

It can only be used after it is defined.

Arrow Function

const hello = () => {
console.log("Hello, world!");
};