Skip to main content

Command Palette

Search for a command to run...

JavaScript Function

A quick guide to javaScript function

Published
•1 min read•View as Markdown
JavaScript Function

What is a function in JavaScript?

A function can be defined as a piece or block of code which is executed to perform a specific task. Functions allow us to define a block of code, give it a name and then execute it as many times as we want. We can define a JavaScript function using the keyword function.

Let’s explore JavaScript functions in detail

Function declarations

Syntax

function name (parameter1,parameter2,..){
//block of code
}
name()

Parameters and Arguments

Parameter are variables declared while defining a function where as, Arguments are variables which are passed to function definition when the function is called.

Example:

par example.jfif