Call a function in JavaScript
javascript
Updated August 29, 2026
Declare a function and call it by writing its name followed by parentheses:
function greet(name) {
return `Hello, ${name}`;
}
const message = greet('Ada');
console.log(message);
Arguments go inside the parentheses. A function expression or arrow function is called the same way after its variable has been initialized:
const double = (value) => value * 2;
double(4);
An object method is called through its object, such as user.save(). Function.prototype.call() and apply() can choose the this value for a regular function, but arrow functions keep the surrounding this and ignore a replacement. Use these methods for a clear reason; eval() is not a general way to call a function and creates security and maintenance problems.
Sources
related.
Ruslan Osipov
About the author