What are functions in JavaScript?

JavascriptWeb DevelopmentFront End Technology

A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code repeatedly. It helps programmers in writing modular codes.

 Before we use a function, we need to define it. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces. 


The following is the syntax −

   function functionname(parameter-list)
Published on 16-Feb-2018 15:40:15