JavaScript Function Complete Reference
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 Parameters | Function 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 Parameters | Function 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 parameter | Rest 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 Property | JavaScript function.length property of the function object in Javascript is used to return the number of parameters required by a function. |
| JavaScript function.displayName Property | JavaScript function.displayName property in JavaScript is used to set the display name of the function. |
| JavaScript function.caller Property | JavaScript function.caller property of the JavaScript function object returns the function that invoked the specified function. |
| JavaScript function.name Property | JavaScript function.name property of the javascript object is used to return the name of the function. |
Functions:
JavaScript Functions | Description |
|---|---|
| JavaScript apply() Function | The 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() Function | The 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() Function | The 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() Function | The unescape() function in JavaScript takes a string as a parameter and uses it to decode that string encoded by the escape() function. |
| JavaScript escape() Function | The 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() Function | The Number() function is used to convert the data type to a number. |
| Index inside map() Function | In 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() Function | JavaScript String() function is used to convert the value of an object to a string value. |
| Javascript eval() Function | JavaScript eval() function is used to evaluate the expression. If the argument represents one or more JavaScript statements, eval() evaluates the statements. |
| JavaScript uneval() Function | JavaScript uneval() is an inbuilt function in JavaScript that is used to create a string representation of the source code of an Object. |
| JavaScript parseInt() Function | JavaScript parseInt() function is used to accept the string and radix parameter and convert it into an integer. |
| JavaScript parseFloat() Function | JavaScript parseFloat() function is used to accept the string and convert it into a floating-point number. |
| JavaScript console.log() Function | JavaScript 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 Binding | In JavaScript, function binding happens using bind() method. |
| JavaScript Function Invocation | JavaScript 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 Expression | Function 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 Functions | Arrow 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 Functions | A Pure Function is a function (a block of code) that always returns the same result if the same arguments are passed. |
| JavaScript Nested Functions | JavaScript 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). |






Please Login to comment...