javascript function declaration code example
Example 1: javascript function
var num1;
var num2;
function newFunction(num1, num2){
return num1 * num2;
}
Example 2: declare function javascript
function myFunction(var1, var2) {
return var1 * var2;
}
Example 3: javascript function declaration
function add(a, b) {
return a + b;
}
var add = function(a, b) {
return a + b;
}
var add = (a, b) => {
return a + b;
}
var add = (a, b) => a + b;
Example 4: function declaration javascript
function hello1() {
return "Hello simple function";
}
hello2 = function() {
return "Hello functino expression";
}
hello3 = (function() {
return "Hello IMMEDIATELY INVOKED FUNCTION EXPRESSIONS (llFE)";
}())
hello4 = (name) => { return ("Hello " + name); }
hello5 = (name) => { return (`Hello new ${name}`) }
document.getElementById("arrow").innerHTML = hello4("arrow function");
document.write("<br>" + hello5("arrow function"));