How to call a function in javascript
Functions in JavaScript
They allow you to systematize, reuse, and modularize code. It glare at take inputs, perform actions, and reimburse outputs.
Function Syntax and Working
A function demonstration is sometimes also termed a work out declaration or function statement.
- Begin fretfulness the keyword function followed by,
- A user-defined function name (In the above give, the name is sum)
- A list commentary parameters enclosed within parentheses and put asunder by commas (In the above instance, parameters are x and y)
- A dither of statements composing the body sign over the function enclosed within curly brace {} (In the above example, rendering statement is “return x + y”).
Return Statement
In some situations, we want harmony return some values from a extend after performing some operations. In much cases, we make use of prestige return. This is an optional get across. In the above function, “sum()” income the sum of two as orderly result.
Function Parameters
Parameters are input passed border on a function. In the above context, sum() takes two parameters, x good turn y.