0% found this document useful (0 votes)
3 views1 page

Javascript

The document explains two methods of function assignment in JavaScript: named and anonymous functions. It discusses hoisting, which is the automatic process of moving function declarations to the top of the file, and provides examples of function definitions that handle different numbers of parameters. Additionally, it introduces the rest operator for variable-length arguments and mentions default parameters.

Uploaded by

Anant Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Javascript

The document explains two methods of function assignment in JavaScript: named and anonymous functions. It discusses hoisting, which is the automatic process of moving function declarations to the top of the file, and provides examples of function definitions that handle different numbers of parameters. Additionally, it introduces the rest operator for variable-length arguments and mentions default parameters.

Uploaded by

Anant Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Javascript

Function assignment can be done in two ways:-

1. Named Function assignment


2. Anonymous function assignment

 Hoisting***
Process of moving Function Declaration to the top of file.
 Done automatically by Js Engine

Function sum (a,b){


Return a+b;  For only 2 input parameters not for 1 and 0 parameters
} here, arguments will create an object not an array

Function sum(a,b){
Let total =0;
for(let value of arguments)  For any no. of input parameters
Total= total value;
Return total;
}

Rest Operator:- Denoted by (…)

Function sum(…args){

[Link](args);

 rest parameter should be last parameter and it is in array

Sum(1,2,3,4,5,6);

Default Parameter:-

You might also like