What are the different ways to declare a function in JavaScript?

Beginner

Answer

// Function declaration
function myFunction() { }
// Function expression
const myFunction = function() { };
// Arrow function
const myFunction = () => { };
// Function constructor (rarely used)
const myFunction = new Function('return 1');