File tree 2 files changed +51
-0
lines changed
2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8
+ < title > Default parameters</ title >
9
+ < link rel ="stylesheet " type ="text/css " href ="">
10
+ </ head >
11
+
12
+ < body >
13
+
14
+ < script src ="js/80-default-parameter.js "> </ script >
15
+ </ body >
16
+
17
+ </ html >
Original file line number Diff line number Diff line change
1
+
2
+ /*function talk(msg) {
3
+ console.log(msg);
4
+ }
5
+
6
+
7
+ talk("hello"); //hello
8
+
9
+ //now we forgot to pass the parameter
10
+ talk(); //undefined
11
+
12
+
13
+ //default parameter means kuchh pass na ho to kuchh default pass hone chahiye.
14
+ function talk(msg = "hi") { //agar str h to "" m denge. agar normal no h to msg=2 is tarh denge
15
+ console.log(msg);
16
+ }
17
+
18
+
19
+ talk(); //hi
20
+ talk("bro"); //bro
21
+ talk(3); //3
22
+ */
23
+ //means jb kuchh parameter nhi pass kare to function ka by default argument set karna taki undefiend nhi aaye.
24
+
25
+
26
+
27
+ function talk ( msg = "hi" , num = 3 ) {
28
+ console . log ( msg ) ;
29
+ console . log ( num ) ;
30
+ }
31
+ talk ( "hero" ) ; //hero
32
+ talk ( ) ; //hi 3
33
+ talk ( "hk" , 4 ) ; //hk,4
34
+ talk ( 6 ) ; //6 3
You can’t perform that action at this time.
0 commit comments