JavaScript Code

Function Syntax in JavaScript

Function Syntax

function functionName(parameter1, parameter2) {


  • function is a keyword
  • functionName is the name of the function, by which it is called
  • parameter1, parameter2,.. are the parameters. arguments received by the function are received in parameters. Any number of parameters can be defined.
  • code is any valid JavaScript code.


1. In the following program, we write a function add() that takes three arguments, and returns their sum.

function add(a, b, c) {
  result = a + b + b;
  return result;

console.log(add(5, 4, 7));