-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
50 lines (32 loc) · 778 Bytes
/
functions.js
File metadata and controls
50 lines (32 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// function in js without parameters
function sayhello(){
console.log('hello from function');
}
sayhello();
//addition function
function addnum(a,b){
return(a+b);
}
console.log(addnum(4,5));
addnum(4,5);
// in java function is like public static int add(int a ,int b){}
//Storing functions,(Functions are called first class citizens as they can be stored in variables)
let a = function sub(x,y){
return x-y;
}
console.log(a(10,3));
//IIFE - Immediately invoked function;
//IIFE without parameters
(function(){
console.log("hello from IIFE");
})();
//IIFE with parameters
(function(x,y){
console.log(x/y);
})(10,5);
(function(){
console.log("hello practice IIFE");
})();
(function(a,b){
console.log(a+b);
})(10,15);