JAVASCRIPT

Calling a Function


Calling a function in JavaScript involves invoking or executing the function to perform its defined task. Functions can be called by using their names followed by parentheses().

 

Syntax:

// Syntax
function function_name(parameter1, parameter2,...) {
    // Your code
    return value;
}

// Calling the function
function_name(arguments...);

 

Example:

// Define a function named "hello"
function hello(name) {
    console.log("Welcome, " + name + "!");
}

// Call the function
hello("Coders"); // Output: Welcome, Coders!