2.
Which of the following is the correct way to define a function in JavaScript?
function myFunction{}
const myFunction = () => {}
const myFunction = function() {}
function myFunction() {}
Correct: B, C, D
function myFunction() {} is the traditional function declaration, const myFunction = function() {} is the function expression assigned to a variable and const myFunction = () => {} is arrow function assigned to a variable. function myFunction{} is not correct is because it lacks the required parentheses () immediately following the function name.