Open In App

JavaScript Function Complete Reference

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The JavaScript function is a set of statements that take inputs, do some specific computation, and produce output. Basically, a function is a set of statements that performs some tasks or does some computation and then return the result to the user.

Syntax:

function functionName(Parameter1, Parameter2, ..) {
    // Function body
}

Example: Below is a sample program that illustrates the working of functions in JavaScript:

Javascript




// Function definition
function welcomeMsg(name) {
    console.log("Hello " + name 
        + " welcome to GeeksforGeeks");
}
  
// creating a variable
let nameVal = "Admin";
  
// calling the function
welcomeMsg(nameVal);


Output:

Hello Admin welcome to GeeksforGeeks

The Complete List of JavaScript Functions & Properties are listed below:

JavaScript Function Parameters:

 Parameters

Description

Example

Function  The function definition and real values passed to the function in the function definition are known as arguments.
Try

Rest  Improved way to handle function parameters defined, allowing us to more easily handle various inputs as parameters in a function.
Try

Default parameters In JavaScript, the parameters of functions default to undefined. However, in some situations, it might be useful to set a different default value. 
Try

JavaScript Functions  Properties:

Properties

Description

Example

length  Return the number of parameters required by a function.
Try

displayName Set the display name of the function.
Try

caller  Returns the function that invoked the specified function.
Try

name Return the name of the function.
Try

JavaScript Functions:

 Functions

Description

Example

apply() It is different from the function call() because it takes arguments as an array.
Try

isFinite() It returns true for all the values except +infinity, -infinity, or NaN.
Try

isNaN() It returns true if the value is a NaN else returns false.
Try

unescape() It decodes that string encoded by the escape() function.
Try

escape() It can be transmitted to any computer in any network which supports ASCII characters.
Try

number() Convert the data type to a number.
Try

map() The calling function for each and every array element in an array.
Try

String() Convert the value of an object to a string value.
Try

eval() If the argument represents one or more JavaScript statements, eval() evaluates the statements.
Try

uneval() Create a string representation of the source code of an Object.
Try

parseInt() Accept the string and radix parameters and convert them into an integer.
Try

parseFloat() Accept the string and convert it into a floating-point number.
Try

console.log() To print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.
Try

Basics of Functions:

JavaScript Operations on Function

Description

Example

Function Generator It needs to generate a value, it does so with the yield keyword rather than return. 
Try

Function Binding In JavaScript, function binding happens using bind() method. 
Try

Function Invocation It is common to use the term “call a function” instead of “invoke a function”. 
Try

Function Expression Create an anonymous function that doesn’t have any function name. 
Try

Arrow Functions Provide generator functions with a concise way to write functions in JavaScript. 
Try

Async Function It checks that we are not breaking the execution thread.
Try

Pure Functions Returns the same result if the same arguments are passed.
Try

Nested Functions Return is a combination of the output from the outer as well as the inner function(nested function).
Try



Last Updated : 24 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads