-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAnonymousfunctasparams.html
More file actions
46 lines (40 loc) · 1.34 KB
/
Anonymousfunctasparams.html
File metadata and controls
46 lines (40 loc) · 1.34 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>My cool stuff</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script src="script.js">
function sum(firstNum,secondNum)
{
return firstNum+secondNum;
}
function dif(firstNum,secondNum)
{
return firstNum-secondNum;
}
function calculate(firstNum,secondNum, calculator)
{
return calculator(firstNum,secondNum);
}//this is a function declaration statement
var cal=calculate(3,9,dif);
var multiplication=calculate(10,12, function(firstNum, secondNum){
//we are initializing the calculate function of calculator value aka invokation statement
return firstNum*secondNum;
});
function newFunction(){
return function()
{
alert("Hello Google how are y'all!");
};
}
var stncnfsuomynonafogninruter=newFunction();//we turned this variable into a function
stncnfsuomynonafogninruter();
alert(multiplication);
//How to return anonymous functions
</script>
</body>
</html>