- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction5.html
More file actions
Latest commit
160 lines (144 loc) · 3.9 KB
/
Copy pathfunction5.html
File metadata and controls
160 lines (144 loc) · 3.9 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>demo</title>
</head>
<body>
<!--=====Function 1 alert with function======-->
<inputtype="button" onclick="sayHello()" value="Say Hello">
<script>
functionsayHello(){
alert('helllloo');
}
</script>
<!--=====Function 2 alert data with function======-->
<inputtype="button" onclick="multiPly(2, 2)" value="Say Hello">
<script>
functionmultiPly(a,b){
alert(a*b);
}
</script>
<!--=====Function 3 print data with var function=====-->
<pid="demo"></p>
<script>
varx=functionmyFunc(a,b){
returna*b;
}
document.getElementById('demo').innerHTML=x(3,3);
</script>
<!--=====Function 4 print value with function======-->
<pid="demo14"></p>
<script>
functionmyFunc2(a,b){
returna*b;
}
varx=myFunc2(4,4);
document.getElementById('demo14').innerHTML=x;
</script>
<pid="demo41"></p>
<script>
vara=6;
functionmyFunc3(a){
returna*a;
}
document.getElementById('demo41').innerHTML=myFunc3(5)*6;
</script>
<!--=====Function 5 anonymous / function expression======-->
<pid="demo3"></p>
<script>
varx=function(a,b){
returna*b;
}
document.getElementById('demo3').innerHTML=x(6,6);
</script>
<!--=====Function 6 print data with var function======-->
<pid="demo6"></p>
<script>
functionmyFunc4(a,b){
returna*b;
}
varx=myFunc4(7,7)*7;
document.getElementById('demo6').innerHTML=x;
</script>
<!--=====Function 7 object function======-->
<pid="demo4"></p>
<script>
varperson={
firstname : 'John',
lastname : 'Shaw',
gender : 'Male',
fullname : function(){
returnthis.firstname+this.lastname;
}
}
document.getElementById('demo4').innerHTML=person.firstname;
</script>
<!--=====Function 8 concatenate function======-->
<pid="demo22"></p>
<inputtype="button" onclick="secondFunction()" value="Call Function">
<script>
functionmyFunc5(first,last){
returnfirst+last;
}
functionsecondFunction(){
varx=myFunc5('Abinash','Saha');
document.getElementById('demo22').innerHTML=x;
}
</script>
<!--=====Function 9 object constructor call function======-->
<pid="demo9"></p>
<script>
varper={
fullname2 : function(age,city){
returnthis.firstname2+this.lastname2+age+city;
}
}
vargroupA={
firstname2 : 'Abinash',
lastname2 : 'Saha'
}
vargroupB={
firstname2 : 'Aniket',
lastname2 : 'Sahu'
}
varx=per.fullname2.call(groupB,'5','Jamshedpur');
document.getElementById('demo9').innerHTML=x;
</script>
<!--=====Function 11 object constructor apply function======-->
<pid="demo12"></p>
<script>
varte={
fullname3 : function(player1,player2){
returnthis.first2+this.last2+player1+player2;
}
}
varteamA={
first2 : 'India',
last2 : 'Australia'
}
varteamB={
first2 : 'Srilanka',
last2 : 'South Africa'
}
varx=te.fullname3.apply(teamB,['Aniket','Abinash']);
document.getElementById('demo12').innerHTML=x;
</script>
<!--=====Function 12 object constructor new function=====-->
<pid="demo2"></p>
<script>
varx=newFunction('a','b','return a * b');
document.getElementById('demo2').innerHTML=x(7,7);
</script>
<!--=====Function 13 consturctor value new function======-->
<pid="demo8"></p>
<script>
functionmyFunc6(a,b){
this.groupA=a;
this.groupB=b;
}
vary=newmyFunc6('John','Doe');
document.getElementById('demo8').innerHTML=y.groupB;
</script>
</body>
</html>