Functions in javascript

Functions:-Functions in JavaScript provide organized, reusable code to perform a set of actions. Functions simplify the coding
process, prevent redundant logic, and make code easier to follow.

1.Named Function

function myfunction(){


This content originally appeared on DEV Community and was authored by Buddhadeb Chhetri

Functions:-Functions in JavaScript provide organized, reusable code to perform a set of actions. Functions simplify the coding
process, prevent redundant logic, and make code easier to follow.

1.Named Function

function myfunction(){
    console.log('Budddhadeb Chhetri');
   }
myFunction(); //Prints: Buddhadeb Chhetri

2.Named Function with arguments

function myFunction(parameter){ 
   console.log('parameter');                                                       
  }
myFunction(10); //Prints:10

3.Anonymous function

const myFunction =function(){
   console.log('Buddhadeb Chhetri');
}
myFunction(); //Prints: Buddhadeb Chhetri

4.Anonymous function with arguments

const myFunction = function(parameter){
  console.log (parameter);
}
myFunction(10); //Prints: 10

5.Arrow function with no argument

const myFunction = ()=>{
  console.log ('Buddhadeb');
}
myFunction(); //Prints: Buddhadeb

6.Arrow function with a single argument

const myFunction = parametrt()=>{
  console.log (parameter);
}
myFunction(20); //Prints: 20

7.Arrow function with a two arguments

const mysum = (param1,param2)=>{
  console.log (param1+param2);
}
myFunction(2,5); //Prints: 7

8.Concise arrow funtion with arguments

const mySum = (a,b)=>a+b;
console.log (2,5); //Prints: 7


This content originally appeared on DEV Community and was authored by Buddhadeb Chhetri


Print Share Comment Cite Upload Translate Updates
APA

Buddhadeb Chhetri | Sciencx (2021-07-31T23:23:11+00:00) Functions in javascript. Retrieved from https://www.scien.cx/2021/07/31/functions-in-javascript-2/

MLA
" » Functions in javascript." Buddhadeb Chhetri | Sciencx - Saturday July 31, 2021, https://www.scien.cx/2021/07/31/functions-in-javascript-2/
HARVARD
Buddhadeb Chhetri | Sciencx Saturday July 31, 2021 » Functions in javascript., viewed ,<https://www.scien.cx/2021/07/31/functions-in-javascript-2/>
VANCOUVER
Buddhadeb Chhetri | Sciencx - » Functions in javascript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/31/functions-in-javascript-2/
CHICAGO
" » Functions in javascript." Buddhadeb Chhetri | Sciencx - Accessed . https://www.scien.cx/2021/07/31/functions-in-javascript-2/
IEEE
" » Functions in javascript." Buddhadeb Chhetri | Sciencx [Online]. Available: https://www.scien.cx/2021/07/31/functions-in-javascript-2/. [Accessed: ]
rf:citation
» Functions in javascript | Buddhadeb Chhetri | Sciencx | https://www.scien.cx/2021/07/31/functions-in-javascript-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.