Skip to content
Related Articles

Related Articles

JavaScript Function Complete Reference

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 21 Nov, 2022
Improve Article
Save Article

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




<script type = "text/javascript">
    // Function definition
    function welcomeMsg(name) {
    console.log("Hello " + name +" welcome to GeeksforGeeks");
    }
      
    // creating a variable
    var nameVal = "Admin";
      
    // calling the function
    welcomeMsg(nameVal);
</script>

Output:

Hello Admin welcome to GeeksforGeeks

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

Parameters :

JavaScript Function Parameters

Description

JavaScript Function ParametersFunction Parameters are the names that are defined in the function definition and real values passed to the function in the function definition are known as arguments.
JavaScript Function ParametersFunction Parameters are the names that are defined in the function definition and real values passed to the function in the function definition are known as arguments.
JavaScript Rest parameterRest parameter is an improved way to handle function parameters defined, allowing us to more easily handle various inputs as parameters in a function.

Properties:

JavaScript Functions Properties

Description

JavaScript function.length PropertyJavaScript function.length property of the function object in Javascript is used to return the number of parameters required by a function.
JavaScript function.displayName PropertyJavaScript function.displayName property in JavaScript is used to set the display name of the function.
JavaScript function.caller PropertyJavaScript function.caller property of the JavaScript function object returns the function that invoked the specified function.
JavaScript function.name PropertyJavaScript function.name property of the javascript object is used to return the name of the function.

Functions:

JavaScript Functions

Description

JavaScript apply() FunctionThe apply() method is used to write methods, which can be used on different objects. It is different from the function call() because it takes arguments as an array.
JavaScript isFinite() FunctionThe JavaScript isFinite() function is used to check whether a number is a finite, legal number or not. It returns true for all the values except +infinity, -infinity, or NaN.
JavaScript isNaN() FunctionThe isNaN() function is used to check whether a given value is an illegal number or not. It returns true if the value is a NaN else returns false.
JavaScript unescape() FunctionThe unescape() function in JavaScript takes a string as a parameter and uses it to decode that string encoded by the escape() function.
JavaScript escape() FunctionThe escape() function takes a string as a parameter and encodes it so that it can be transmitted to any computer in any network which supports ASCII characters.
Javascript number() FunctionThe Number() function is used to convert the data type to a number.
Index inside map() FunctionIn JavaScript, map() method handles array elements, which creates a new array with the help of results obtained from the calling function for each and every array element in an array.
JavaScript String() FunctionJavaScript String() function is used to convert the value of an object to a string value.
Javascript eval() FunctionJavaScript eval() function is used to evaluate the expression. If the argument represents one or more JavaScript statements, eval() evaluates the statements.
JavaScript uneval() FunctionJavaScript uneval() is an inbuilt function in JavaScript that is used to create a string representation of the source code of an Object.
JavaScript parseInt() FunctionJavaScript parseInt() function is used to accept the string and radix parameter and convert it into an integer.
JavaScript parseFloat() FunctionJavaScript parseFloat() function is used to accept the string and convert it into a floating-point number.
JavaScript console.log() FunctionJavaScript console.log() is a function in JavaScript that is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.

Basics of Functions:

JavaScript Operations on Function

Description

JavaScript Function Generator A generator function is defined like a normal function, but whenever it needs to generate a value, it does so with the yield keyword rather than return. 
JavaScript Function BindingIn JavaScript, function binding happens using bind() method. 
JavaScript Function InvocationJavaScript Function Invocation is used to execute the function code and it is common to use the term “call a function” instead of “invoke a function”. 
JavaScript Function ExpressionFunction Expression allows us to create an anonymous function that doesn’t have any function name which is the main difference between Function Expression and Function Declaration. 
JavaScript Arrow FunctionsArrow functions, introduced in ES6, provide generator functions with a concise way to write functions in JavaScript. 
JavaScript Async Function It simply allows us to write promise-based code as if it was synchronous and it checks that we are not breaking the execution thread.
JavaScript Pure FunctionsA Pure Function is a function (a block of code) that always returns the same result if the same arguments are passed.
JavaScript Nested FunctionsJavaScript support nested functions. In the examples given below the output returning is a combination of the output from the outer as well as inner function(nested function).

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!