types of functions in javascript
/* Declare function */
function myFunc(param) {
// Statements
}function myfunction() {
console.log("function");
};
myfunction() //Should say "function" in the console.
function calculate(x, y, op) {
var answer;
if ( op = "add" ) {
answer = x + y;
};
else if ( op = "sub" ) {
answer = x - y;
};
else if ( op = "multi" ) {
answer = x * y;
};
else if ( op = "divide" ) {
answer = x / y;
};
else {
answer = "Error";
};
return answer;
};
console.log(calculate(15, 3, "divide")); //Should say 5 in console.
//I hope I helped!// Named function
function add(x: number, y: number): number {
return x + y;
}
// Anonymous function
let myAdd = function (x: number, y: number): number {
return x + y;
};Named function
Anonymous function
Immediately invoked function expression.interface Param {
title: string;
callback: function;
}
Also in JavaScript:
- adonis limit
- get value of input jqueyr
- for function js
- how to change currency in react-paypal-button-v2
- install php7 runtime brackets
- jquery ajax CORS
- how to add oAuth google signin in react native app
- how to add first child using js
- jquery only number allowed to 10 digit
- sweetalert2 js
- dynamodb get all items nodejs
- scrollheight jquery
- compile angularjs template
- javascript sum of arguments
- javascript list length
- how to create duplicate key array in javascript
- chartjs how to disable hover lable
- jquery radio button checked event
- how to set height of material ui dialog react
- react latest version
- Can't bind to 'ngForOf' since it isn't a known property of 'th'
- javascript clear div
- in object transform translate property concat with rotate value angular 7
- toLocalString