Yes, it is possible to pass a function as a parameter in JavaScript. This is a common feature in JavaScript and is frequently used in higher-order functions, callback functions, and event handlers.
function greet(name) {
return `Hello, ${name}!`;
}
function displayGreeting(greetingFunction, name) {
console.log(greetingFunction(name));
}
displayGreeting(greet, 'Alice'); // Outputs: Hello
, Alice!