Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

three ways of writing a function in javascript

//Three ways of writing a function in javascript
//1 Function declaration
function add(a, b) {		
	console.log(a + b);
}
// Calling it
add(2, 3);

//2 Function Expression
const add = function(a, b) {
	console.log(a+b);
}
// Calling it
add(2, 3);

//3 Arrow function (for Single line of code)
let add = (a, b) => a + b; //inbuilt return
console.log(add(3, 2));
Comment

PREVIOUS NEXT
Code Example
Javascript :: selectboxit 
Javascript :: opacity material ui 
Javascript :: remove all chars from string and leave only numbers javascript and leav space betwin numbers 
Javascript :: EXPRESS APP REGISTER HANDLEBARS VIEW ENGINE 
Javascript :: node js hello word 
Javascript :: jquery how to get element insde div 
Javascript :: how to print elements in an array in javascript 
Javascript :: clear input fild 
Javascript :: javascript check type of variable var 
Javascript :: mongoose encrypt database using mongoose encrypt package 
Javascript :: how to check with jquery if bootstrap modal is hidden or shown 
Javascript :: Create A React State 
Javascript :: Nextjs mongodb connection setup 
Javascript :: vue not loading env variables 
Javascript :: json regex 
Javascript :: sleep 1 second 
Javascript :: von click 
Javascript :: print json object 
Javascript :: sequelize exclude attributes 
Javascript :: select div with clas 
Javascript :: javascript getHours from epoch 
Javascript :: .html jquery in javascript 
Javascript :: js addeventlistener input searcb mobile 
Javascript :: vue mixin example 
Javascript :: gsap keyframes 
Javascript :: get ip address with js 
Javascript :: area selection on image using javascript 
Javascript :: deserialize json to c# object 
Javascript :: Invalid prettier configuration file detected. See log for details. 
Javascript :: convert date format mm/dd/yyyy to yyyymmdd in javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =