Skip to content

Commit bd27419

Browse files
committed
add all 80 default parameter
1 parent 795d252 commit bd27419

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

80-default-parameter.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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>

js/80-default-parameter.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

0 commit comments

Comments
 (0)